scanf无法换行怎么解??
#include "stdio.h"#include "string.h"
int main()
{
struct stu
{
int sno;
char name[10];
char sex;
float score;
}student[5];
int i=0,count;
float sum=0;
while(i<5)
{
printf("请输入%d个学生学号:\n",i+1);
scanf("%d",&student[i].sno); //scanf会读回车进去,无法换行?
printf("请输入学生姓名:\n");
gets(student[i].name);
printf("请输入学生性别:\n");
scanf("%c",&student[i].sex);
printf("请输入学生成绩:\n");
scanf("%f",&student[i].score);
if(student[i].score<60.0)
count++;
sum=sum+student[i].score;
i++;
}
printf("学号\t\t姓名\t\t性别\t\t分数\n");
for(i=0;i<5;i++)
printf("%d\t\t%s\t\t%c\t\t%f\n",student[i].sno,student[i].name,student[i].sex,student[i].score);
printf("不及格人数%d\t平均成绩%f\n",count,sum/5);
return 0;
}