用 linq int maxValue = check.Max(); 这是找到最大的值 再用 indexOf 去找索引
int index = -1; for (int i = 0, max = int.MinValue; i < check.Length; i++) { if (check[i] > max) { index = i; max = check[i]; } } Console.WriteLine(index);
int index_max = 0; int value_max = checked[0]; for (int i = 1; i < checked.Length; ++i) { if (checked[i] > value_max) { value_max = checked[i]; index_max = if; } }index_max就是最大数的索引
int maxValue = check.Max();
这是找到最大的值
再用 indexOf 去找索引
for (int i = 0, max = int.MinValue; i < check.Length; i++)
{
if (check[i] > max)
{
index = i;
max = check[i];
}
}
Console.WriteLine(index);
int value_max = checked[0];
for (int i = 1; i < checked.Length; ++i)
{
if (checked[i] > value_max)
{
value_max = checked[i];
index_max = if;
}
}index_max就是最大数的索引