比如说我想在结构体中输入:
#include
struct score
{
int num;
char c[6];
int M;
int E;
int Chi;
int P;
int Che;
int sum;
};
void main()
{
struct score student[3];
int i;
for(i=0;i<3;i++)
{
scanf("%d%c%d%d%d%d%d",&student[i].num,&student[i].M,&student[i].E,&student[i].Chi,&student[i].P,&student[i].Che);
student[i].sum=student[i].M+student[i].E+student[i].Chi+student[i].P+student[i].Che;
}
for(i=0;i<3;i++)
printf("num=%d\tM=%d\tE=%d\tChi=%d\tP=%d\tChe=%d\tsum=%d\t",student[i].num,student[i].M,student[i].E,student[i].Chi,student[i].P,student[i].Che,student[i].sum);
}
我的输入语句【scanf("%d%c%d%d%d%d%d",&student[i].num,&student[i].M,&student[i].E,&student[i].Chi,&student[i].P,&student[i].Che);
】在执行的时候,只能输入一次,且结果是随机数,这是怎么回事?
我应该怎样改会方便输入?