结构体实验-参考答案.docxVIP

  • 0
  • 0
  • 约6.01千字
  • 约 9页
  • 2022-05-26 发布于湖北
  • 举报
实验九 结构体 1.有 5 个学生,每个学生有 3 门课的成绩,从键盘输入以上数据(包括学号、姓名、3 门 课成绩),计算出每个学生的总成绩,并将总成绩最高的学生信息(包括学号、姓名、3 门 课成绩、总成绩)输出。 #include stdio.h struct STU{ char number[7]; char name[10]; int score[3]; int total; }student[5]; int main() { int i,j,n; printf(请输入 5 个学生的学号、姓名、3 门课成绩: \n); for(i=0;i5;i++) { student[i].total=0; scanf(%s%s,student[i].number,student[i].name); for(j=0;j3;j++){ scanf(%d,student[i].score[j]); student[i].total+=student[i].score[j]; } } printf(\n-------------------- 成绩表-----------------------\n); printf( 学号 姓名 数学 语文 英语 总分\n); for(i=0;i5;i++) { printf(%8s%8s,student[i].number,student[i].name)

文档评论(0)

1亿VIP精品文档

相关文档