有5个学生,每个学生的数据包括学号、姓名、三门课的成绩,从键盘输入5个学生数据,在屏幕上输出这些信息。
#include<stdio.h>
struct student
{
int stu_id;
char stu_name[8];
float stu_churse[3];
};
void main()
{
int i;
struct student p;
for(i=0;i<5;i++)
{
printf("input student id:\n");
scanf("%d",&p.stu_id);
printf("input student id:\n");
scanf("%s",p.stu_name);
printf("input student id:\n");
scanf("%f%f%f",&p.stu_course[0],&p.stu_course[1],&p.stu_course[2]);
printf("id name churse1 course2 course3\n");
printf("%d%s%f%f%f",p.stu_id,p.stu_name,p.stu_course[0],p.stu_course[1],p.stu_course[2]);
}
}
请问这个程序错在哪里
最佳答案
语法上,你有拼写错
定义的是
stu_churse
而使用的是
stu_course
(改为这个可以编译运行了。。。)
另外,你提示都是input student id
且输出最后少回车了
再有,只是输入直接输出的话,可不用结构的
其他回答
暂无其它回答!