我编写了一个基本程序来查找数组中的最大数并打印它:
#include <stdio.h>
int main(void)
{
int numbers[] = {3, 5, 12, 1, 4};
int largest;
largest = numbers[0];
for (int i = 0; i < sizeof(numbers) / sizeof(numbers[0]); i++)
{
if (largest < numbers[i])
{
largest = numbers[i];
}
}
printf("The largest number in the array is %i\n", largest);
}
我需要做什么才能打印而不是The largest number in the array is 12
打印The largest number in the array is numbers[2]
?