From 99d098c39ba0cdf5e099d3fb0f70c2b2d8d98128 Mon Sep 17 00:00:00 2001 From: pv7g39eqr <2500187549@qq.com> Date: Sun, 12 Nov 2023 19:12:37 +0800 Subject: [PATCH] ADD file via upload --- ...97e19_1bac75b180f4d29671ce958dfd00e50c_8.c | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 bd6096c6001c347d51fa34d55a897e19_1bac75b180f4d29671ce958dfd00e50c_8.c diff --git a/bd6096c6001c347d51fa34d55a897e19_1bac75b180f4d29671ce958dfd00e50c_8.c b/bd6096c6001c347d51fa34d55a897e19_1bac75b180f4d29671ce958dfd00e50c_8.c new file mode 100644 index 0000000..ec7550b --- /dev/null +++ b/bd6096c6001c347d51fa34d55a897e19_1bac75b180f4d29671ce958dfd00e50c_8.c @@ -0,0 +1,55 @@ +#include +struct Scoreb{ + int schoolnumber; + int classnumber; + char name[20]; + float math; + float physics; + float english; + float sum; +}; +int main(){int i,j,k,m; + //初始化 +struct Scoreb student1={10001,11,"Zhang",99.5,88.5,89.5,277.5}; + struct Scoreb student2={10002,12,"Yang",77.9,56.5,87.5,221.9}; + struct Scoreb student3={10003,11,"Liang",92.5,99.0,60.5,252}; + struct Scoreb students[3] = {student1,student2,student3}; + //修改信息 + struct Scoreb schange;printf("依次输入学号班级姓名三科成绩:"); + scanf("%d%d%s%f%f%f",&schange.schoolnumber,&schange.classnumber,&schange.name,&schange.math,&schange.physics,&schange.english);int c=schange.schoolnumber; + for(m=0;m<3;m++){ + if(schange.schoolnumber==students[m].schoolnumber){ + schange.sum = schange.math+schange.physics+schange.english; + students[m]=schange; + } + } + //排序 + for(j = 0 ; j < 3 ; j++) + for(k = 2; k > j;k--){ + if(students[k].classnumber students[k-1].sum){ + struct Scoreb temp2 = students[k-1]; + students[k-1] = students[k]; + students[k] = temp2; + }//由高到低 + //内嵌一个比较 + //按照总成绩排名 + } + } + //输出 + for(i = 0; i < 2 ; i++){ + printf("%d %d %s %.1f %.1f %.1f\n",students[i].classnumber,students[i].schoolnumber,students[i].name,students[i].math,students[i].physics,students[i].english); + if(c==students[i].schoolnumber)printf("modified");if(students[0].classnumber==students[1].classnumber) + { + printf(" %d %s %.1f %.1f %.1f\n",students[1].schoolnumber,students[1].name,students[1].math,students[1].physics,students[1].english);break;} + } + printf("%d %d %s %.1f %.1f %.1f",students[2].classnumber,students[2].schoolnumber,students[2].name,students[2].math,students[2].physics,students[2].english); + if(c==students[2].schoolnumber)printf(" modified"); + return 0; + +}