i被要求在10的数组中找到最大的数字,然后是它的索引。首先,我已经设法使用“ for”循环来找到数组中的最大数字(我们还没有使用任何函数,而是“ Math”),但是我很难获取其索引。]
example:
the array: 1,55,1,7,9,10,1,3,8,10
result:
biggest numbers:55
its index:1 (if we count from 0)
到目前为止我的代码:
int[] numbers = new int[10];
int max = 0;
int count;
for(count=0;count<numbers.Length;count++)
{
numbers[count] = int.Parse(Console.ReadLine());
}
for (count = 0; count < numbers.Length; count++)
{
numbers[0] = max;
if(numbers[count] > max)
{
max = numbers[count];
}
}
Console.WriteLine("the biggest number is" + max);