例题:请补充main函数,该函数的功能是:从键盘输入一组整数,使用条件表达式找出最大的整数。当输入的整数为-1时结束。
例如:输入96 121 23 343 232 54 89 365 89 -1时,最大的数为365。
请勿改动主函数main与其他函数中的任何内容,仅在横线上填写所需的若干表达式或语句。
代码如下:
#include<stdio.h>
#include<conio.h>
#define NUM 100
main()
{
int n[NUM];
int i=-1;
int MAX=-1;
printf("\nInsert integer with the '-1' as end:\n");
do
{
i++;
printf("n[%d]=",i);
scanf("%d",&n[i]);
MAX=MAX<n[i]?n[i]:MAX;
}while(n[i]!=-1);
printf("The MAX=%d\n",MAX);
}
输出运行窗口如下:
越努力越幸运!
加油,奥力给!!!