/* 有10个学生,每个学生的数据包括学号、姓名、3门课程的成绩, 从键盘输人10个学生数据,要求输出3门课程总平均成绩, 以及最高分的学生的数据(包括学号、姓名、3门课程成绩、平均分数)。 */ #include<stdio.h> #include<stdlib.h> struct student{ int num; char name[30]; int score[3]; float avg; }; int sort(struct student *stu); int main() { struct student students[3]; for(int i = 0;i<3;i++) { scanf("%d %s %d %d %d",&students[i].num,students[i].name, &students[i].score[0],&students[i].score[1],&students[i].score[2]); students[i].avg = (students[i].score[0]+students[i].score[1]+students[i].score[2])/3; } int maxi = sort(students); printf("%d %s %d %d %d %lf\n", students[maxi].num, students[maxi].name, students[maxi].score[0], students[maxi].score[1], students[maxi].score[2], (students[maxi].score[0] + students[maxi].score[1] + students[maxi].score[2]) / 3.0); } //选排 int sort(struct student *stu) { int i,j,min,k,tnum,ts1,ts2,ts3; for(i = 0;i<3;i++) { min = stu[i].avg; for(j = i+1;j<3;j++) { if(min<stu[j].avg) { min = stu[j].avg; k = j; } } } return k; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:718 |
陶陶摘苹果 (C语言代码)浏览:1606 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:624 |
简单的a+b (C语言代码)浏览:631 |
1025题解浏览:738 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:486 |
1128题解(返回值为数组的情况)浏览:473 |
震宇大神的杀毒软件 (C语言代码)浏览:1080 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:814 |
整数分类问题 为什么输出总是数字8啊浏览:442 |