郁闷的很,大家看看萨!
#include "stdio.h"struct per
{
long int number;
char name[10];
int age;
union
{
float exam;
char grade;
}score;
};
int main()
{
struct per person[10];
int i=0,pass=0;
for(;i<10;++i)
{
scanf("%ld%s%d",&person[i].number,&person[i].name,&person[i].age);
if(person[i].age<25)
{
printf("exam:");
scanf("%f",&person[i].score.exam);
if(person[i].score.exam<=100&&person[i].score.exam>=60)
++pass;
}
else
{
printf("grade:");
scanf("%c",&person[i].score.grade);
if(person[i].score.grade=='A'||person[i].score.grade=='B'||person[i].score.grade=='C')
++pass;
}
}
printf("%d passed\n",pass);
for(i=0;i<10;++i)
if(person[i].age<25)
printf("%s:%f\n",person[i].name,person[i].score.exam);
else
printf("%s:%c\n",person[i].name,person[i].score.grade);
return 0;
}
请大家指点一下,为什么执行到scanf("%c",&person[i].score.grade);整个for循环就结束了啊?
郁闷的很啊!