我需要从数组中选择10个最小数字(有2 000个项目)并打印它们的索引.
起初我尝试对这个数组进行排序并打印值数组[0到9].这是最小的数字,但我丢失了这个值的索引,他们有非排序数组.
第二个选项尝试使用treeMap,它运行良好,但是当我有两个相同的键时,它只打印其中一个,但我需要打印它们.
使用treeMap的使用代码示例:
TreeMap<Integer, String> treemap = new TreeMap<Integer, String>();
treemap.put(2, "two");
treemap.put(1, "one");
treemap.put(3, "three");
treemap.put(6, "six");
treemap.put(6, "six2");
treemap.put(5, "five");
Collection<String> coll=treemap.values();
System.out.println("Value of the collection: "+coll);
Run Code Online (Sandbox Code Playgroud)
到目前为止我还没有使用treeMap,所以可能会有一些简单的方法来修复它.或者更好地使用其他东西?
我将不胜感激任何帮助
我想尝试使用WebP格式的图像作为我的网页上的背景图像.但是我不确定,如果在这种情况下浏览器不支持WebP格式的CSS如何使用经典的jpg图像.我发现这个示例代码,芽不起作用
.mybackgroundimage {
background-image: url("image.jpg");
background-image: image("image.webp" format('webp'), "image.jpg");
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用来自".hgt"格式文件的二进制数据的应用程序.我在C++中找到了一个解决方案,但是我无法弄清楚如何将该解决方案转换为C.文件中的每个值都是带符号的short int类型,并且有1201x1201的值.
const int SIZE = 1201;
signed short int matrix[SIZE][SIZE] = {0};
int main(int argc, const char * argv[])
{
using namespace std;
ifstream file("N49E013.hgt", ios::in|ios::binary);
unsigned char buffer[2];
for (int i = 0; i < SIZE; ++i)
{
for (int j = 0; j < SIZE; ++j)
{
if(!file.read( reinterpret_cast<char*>(buffer), sizeof(buffer) ))
{
cout << "Error reading file!" << endl;
system("PAUSE");
return -1;
}
matrix[i][j] = (buffer[0] << 8) | buffer[1];
}
}
Run Code Online (Sandbox Code Playgroud) 我在Oracle中创建了我的第一个数据库.我在表二列中有开始日期和结束日期,我需要确保date2(结束日期)不小于date1(开始日期).我认为可以通过触发器执行此操作,但我不知道如何编写此触发器.