问一个问题
#include <stdio.h>main()
{
struct student
{ char num[10];
char name[10];
char sex;
float english;
float computer;
float math;
float total;
float average;
};
struct student per[10];
int i;
for(i=0;i<=9;i++)
{
printf("第%d个同学\n",i+1);
printf("please input the num:");
scanf("%s",per[i].num);
printf("please input the name:");
scanf("%s",per[i].name);
printf("please input the sex M or F:");
scanf(" %c",&per[i].sex); /*为什么%c前的空格不可少*/
printf("please input the english score:");
scanf("%f",&per[i].english);
printf("please input the computer score:");
scanf("%f",&per[i].computer);
printf("please input the math score:");
scanf("%f",&(per[i].math));
per[i].total=per[i].english+per[i].computer+per[i].math;
per[i].average=per[i].total/3;
}
for(i=0;i<=9;i++)
{
printf("%s,%s,%c,%f,%f,%f,%f,%f\n",per[i].num,per[i].name,per[i].sex,per[i].english,per[i].computer,per[i].math,per[i].total,per[i].average);
}
}