在程序编辑区编写程序,给定程序功能是:实现从键盘上输入若干学生的成绩,统计并输出最高成绩,当输入负数时结束输入。例如:
输入:60,70,80,90,100,-1
输出:100
程序有两个空(1)、(2)需要补充完整。并将程序调试出所需的结果。
注意:不要随意改动程序不得增行或删行,也不得更改程序的结构!
#include <stdio.h>
int main(void)
{
int score,max;
____①____;
max= score;
while ( ____ ② ____ )
{
if(max< score)
max=score;
scanf("%d",&score);
}
printf("%d",max);
return 0;
}
① score = 60
② score != -1
供参考:
#include <stdio.h>
int main(void)
{
int score, max;
scanf("%d", &score); //____①____;
max = score;
while (score >= 0) //(____ ② ____)
{
if (max < score)
max = score;
scanf("%d", &score);
}
printf("%d", max);
return 0;
}