From 7eaf94007ddb0573036ad7825a3424f2cf61dcb4 Mon Sep 17 00:00:00 2001 From: p72fupixj Date: Sun, 5 Nov 2023 15:19:09 +0800 Subject: [PATCH] ADD file via upload --- 4.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 4.c diff --git a/4.c b/4.c new file mode 100644 index 0000000..fa50abf --- /dev/null +++ b/4.c @@ -0,0 +1,53 @@ +#include +#define N 3 + +struct stu_info +{ + int num,cls,flag; + float math,physics,english,total; +}; + +struct stu_info 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 stu_info *stu,int n) +{ + int i,j; + struct stu_info 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