diff --git a/1_E2 step4.c b/1_E2 step4.c new file mode 100644 index 0000000..8214f45 --- /dev/null +++ b/1_E2 step4.c @@ -0,0 +1,53 @@ +#include +#define N 3 + +struct student +{ + int num,cls,flag; + float math,physics,english,total; +}; + +struct student stu[N+1]={{10001,11,0,99.5,88.5,89.5,277.5}, + {10002,12,0,77.9,56.5,87.5,221.9}, + {10003,11,0,92.5,99.0,60.5,252},{}}; + +void sort(struct student *stu,int n) +{ + int i,j; + struct student tmp; + for(i=0;icls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->total<(stu+j+1)->total)) + { + tmp = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = tmp; + } + } + } + return; +} + +int main() +{ + scanf("%d",&stu[N].num); + scanf("%d",&stu[N].cls); + scanf("%f",&stu[N].math); + scanf("%f",&stu[N].physics); + scanf("%f",&stu[N].english); + stu[N].flag=1; + stu[N].total=stu[N].math+stu[N].physics+stu[N].english; + int check=1,i,n=N+1; + for(i=0;i