ZACYY542 2021-12-28 14: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 14:56
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 12月29日
  • 已采纳回答 12月28日
  • 修改了问题 12月28日
  • 创建了问题 12月28日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度