diff --git a/T6chang.cpp b/T6chang.cpp new file mode 100644 index 0000000..e1db9c7 --- /dev/null +++ b/T6chang.cpp @@ -0,0 +1,83 @@ +#include +struct stud + { + int num; + int clas; + char name[10]; + float math; + float phy; + float eng; + char modf; + }; +int main() +{ + + struct stud stu[10]={{10001,11,"Zhang",99.5,88.5,89.5}, + {10002,12,"Yang",77.9,56.5,87.5}, + {10003,11,"Liang",92.5,99.0,60.5}, + }; + struct stud t={}; + struct stud ch[1]; + scanf("%d %d %s %f %f %f",&ch[0].num,&ch[0].clas,ch[0].name,&ch[0].math,&ch[0].phy,&ch[0].eng); + struct stud*p=stu; + struct stud*p1=ch; + void change(struct stud stu[],struct stud ch[]); + change(p,p1); + int i,j; + for(i=0;stu[i].num!=0;i++) + { + if(stu[i+1].num!=0) + { + for(j=i+1;stu[j].num!=0;j++) + { + if(stu[i].clas>stu[j].clas) + { + t=stu[i];stu[i]=stu[j];stu[j]=t; + } + } + } + } + for(i=0;stu[i].num!=0;i++) + { + if(stu[i+1].num!=0) + { + for(j=i+1;stu[j].num!=0&&stu[i].clas==stu[j].clas;j++) + { + if(stu[i].math+stu[i].phy+stu[i].eng