ZACYY542 2021-12-28 06:42 采纳率: 62.5%
浏览 39
已结题

输入没问题,打印不了

img

img

img


/*1.有10个学生,每个学生的数据包括学号、姓名、高数课、英语课、程序设计课的成绩。
从键盘输入10个学生的数据,要求输出每个学生三门课程的平均成绩,以及平均成绩最高
的学生的数据(包括学号、姓名、三门课成绩、平均成绩)。 */

#include<stdio.h>
#define N 3 //数据个数
struct STUDENT

{

int   studentID;      /*每个学生的序号*/
char  studentName[N];/*每个学生的姓名*/
float scoreComputer;  /*每个学生的程序设计成绩*/
float scoreEnglish;   /*每个学生的英语成绩*/
float scoreMath;        /*每个学生的高数成绩*/
float Ave;            //平均成绩

};
main()
{
int i,maxpos;
float max;
struct STUDENT stu[N];
for(i=0;i<N;i++)
{
printf("请输入第%d个:",i);
scanf("%d%s%f%f%f",&stu[i].studentID,
stu[i].studentName,
&stu[i].scoreComputer,
&stu[i].scoreEnglish,
&stu[i].scoreMath);
stu[i].Ave=(stu[i].scoreComputer+stu[i].scoreEnglish+stu[i].scoreMath)/3.0;
}
max=stu[0].Ave;
maxpos=0;
if(stu[i].Ave>max)
{
max=stu[i].Ave;
maxpos=i;
}
for(i=0;i<N;i++)
{
printf("%s%s%f%f%f%f",stu[i].studentID,stu[i].studentName[N],stu[i].scoreComputer,stu[i].scoreEnglish,stu[i].scoreMath,stu[i].Ave);
}
printf("平均成绩最高的是:");
printf("%s%s%f%f%f%f",stu[maxpos].studentID,stu[maxpos].studentName[N],
stu[maxpos].scoreComputer,stu[maxpos].scoreEnglish,stu[maxpos].scoreMath,
stu[maxpos].Ave);
}

展开全部

  • 写回答

2条回答 默认 最新

  • 南七灵 2021-12-28 06:56
    关注

    scanf("%d%s%d%f%f",&stu[i].studentID,stu[i].studentName,&stu[i].scoreComputer,&stu[i].scoreEnglish,&stu[i].scoreMath);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
    ZACYY542 2021-12-28 07:08

    改了,但还是没结果

    回复
    南七灵 回复 ZACYY542 2021-12-28 07:10

    发代码

    回复
    ZACYY542 回复 南七灵 2021-12-28 07:12

    /*1.有10个学生,每个学生的数据包括学号、姓名、高数课、英语课、程序设计课的成绩。 从键盘输入10个学生的数据,要求输出每个学生三门课程的平均成绩,以及平均成绩最高 的学生的数据(包括学号、姓名、三门课成绩、平均成绩)。 */ #include<stdio.h> #define N 3 //数据个数 struct STUDENT { int studentID; /*每个学生的序号*/ char studentName[N];/*每个学生的姓名*/ float scoreComputer; /*每个学生的程序设计成绩*/ float scoreEnglish; /*每个学生的英语成绩*/ float scoreMath; /*每个学生的高数成绩*/ float Ave; //平均成绩 }; main() { int i,maxpos; float max; struct STUDENT stu[N]; for(i=0;i<N;i++) { printf("请输入第%d个:",i); scanf("%d%s%f%f%f",&stu[i].studentID, stu[i].studentName, &stu[i].scoreComputer, &stu[i].scoreEnglish, &stu[i].scoreMath); stu[i].Ave=(stu[i].scoreComputer+stu[i].scoreEnglish+stu[i].scoreMath)/3.0; } max=stu[0].Ave; maxpos=0; if(stu[i].Ave>max) { max=stu[i].Ave; maxpos=i; } for(i=0;i<N;i++) { printf("%s%s%f%f%f%f",stu[i].studentID,stu[i].studentName[N],stu[i].scoreComputer,stu[i].scoreEnglish,stu[i].scoreMath,stu[i].Ave); } printf("平均成绩最高的是:"); printf("%s%s%f%f%f%f",stu[maxpos].studentID,stu[maxpos].studentName[N], stu[maxpos].scoreComputer,stu[maxpos].scoreEnglish,stu[maxpos].scoreMath, stu[maxpos].Ave); }

    回复
    展开全部9条评论
查看更多回答(1条)
编辑
预览

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 12月29日
  • 已采纳回答 12月28日
  • 修改了问题 12月28日
  • 创建了问题 12月28日
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部