You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123xj/bd6096c6001c347d51fa34d55a8...

56 lines
2.0 KiB

#include<stdio.h>
struct Scoreb{
int schoolnumber;
int classnumber;
char name[20];
float math;
float physics;
float english;
float sum;
};
int main(){int i,j,k,m;
//<2F><>ʼ<EFBFBD><CABC>
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};
//<2F>޸<EFBFBD><DEB8><EFBFBD>Ϣ
struct Scoreb schange;printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>Ű༶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴɼ<EFBFBD><EFBFBD><EFBFBD>");
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;
}
}
//<2F><><EFBFBD><EFBFBD>
for(j = 0 ; j < 3 ; j++)
for(k = 2; k > j;k--){
if(students[k].classnumber <students[k-1].classnumber){
struct Scoreb temp1 = students[k-1];
students[k-1] = students[k];
students[k] = temp1;
//<2F><><EFBFBD>հ<D5B0><E0BCB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}else if(students[k].classnumber == students[k-1].classnumber){
if(students[k].sum>students[k-1].sum){
struct Scoreb temp2 = students[k-1];
students[k-1] = students[k];
students[k] = temp2;
}//<2F>ɸߵ<C9B8><DFB5><EFBFBD>
//<2F><>Ƕһ<C7B6><D2BB><EFBFBD>Ƚ<EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD>ܳɼ<DCB3><C9BC><EFBFBD><EFBFBD><EFBFBD>
}
}
//<2F><><EFBFBD><EFBFBD>
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;
}