diff --git a/6.cpp b/6.cpp new file mode 100644 index 0000000..dca16e9 --- /dev/null +++ b/6.cpp @@ -0,0 +1,103 @@ +#include +#include +#include +#include +void input(); +void select1(); +void order(); +void output(); +int sum=2; +int flag; +struct stu +{ + int Id; + int clas; + char name[100]; + float score1; + float score2; + float score3; + float score; +}stu[100]={{10001,11,"Zhang",99.5,88.5,89.5,277.5}, +{10002,12,"Yang",77.9,56.5,87.5,221.9}, +{10003,11,"Liang",92.5,99.0,60.5,252}}; +int main() +{ + while(1) + { + input(); + order(); + output(); + + } +} +void input() +{ + sum=sum+1; + scanf("%d",&stu[sum].Id); + flag=stu[sum].Id; + scanf("%d",&stu[sum].clas); + scanf("%s",&stu[sum].name); + scanf("%f",&stu[sum].score1); + scanf("%f",&stu[sum].score2); + scanf("%f",&stu[sum].score3); + stu[sum].score=stu[sum].score3+stu[sum].score2+stu[sum].score1; + select1(); +} +void select1() +{ + int k; + for(int i=0;i<=sum-1;i++) + { + if(stu[i].Id==flag) + { + k=i; + } + } + for(int j=k;j<=sum;j++) + { + stu[j]=stu[j+1]; + } + sum=sum-1; +} +void order() +{ + for(int i=0;i<=sum;i++) + { + for(int j=i;j<=sum;j++) + { + if(stu[i].clas>stu[j].clas) + { + stu[sum+1]=stu[i]; + stu[i]=stu[j]; + stu[j]=stu[sum+1]; + } + else if(stu[i].clas==stu[j].clas) + { + if(stu[i].score