#include <stdio.h>
struct student
{
char name[20];
int score;
}grade[5];
main()
{
int i,avg,sum,b=0,t;
printf("input name and score\n");
for(i=0;i++;i<5)
scanf("%s%d",grade[i].name,&grade[i].score);
for(i=0;i++;i<5)
sum=sum+grade[i].score;
avg=sum/5;
for(i=0;i++;i<5)
{
if(grade[i].score<60)
{
b++;
printf("%s",grade[i].name);
}
}
printf("sum=%d\n",sum);
printf("avg=%d\n",avg);
printf("the number under 60 is=%d\n",b);
}
为什么我执行的时候,没发输入.一按键盘就退出.下次在执行时显示:
"input name and score
sum=2490
avg=498
then nuber under 60 is =0"
怎么会这样,各位帮帮我,我是刚学的,麻烦解释的明白点,多谢
參考答案:for(i=0;i++;i<5) ===> for(i=0;i<5;i++)