From 19ad71cb99ce81be7d77aa430c22c6f1028abb95 Mon Sep 17 00:00:00 2001 From: p9r5svm3g <2687957063@qq.com> Date: Sat, 11 Nov 2023 14:50:44 +0800 Subject: [PATCH] ADD file via upload --- program 6.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 program 6.c diff --git a/program 6.c b/program 6.c new file mode 100644 index 0000000..abac152 --- /dev/null +++ b/program 6.c @@ -0,0 +1,61 @@ +#include +#include +struct stu +{ + char num[20]; + int c,x; + char name[20]; + float m,p,e; +}; + +struct stu stu[3]={{"10001",11,0,"Zhang",99.5,88.5,89.5}, + {"10002",12,0,"Yang",77.9,56.5,87.5}, + {"10003",11,0,"Liang",92.5,99.0,60.5}}; + +void min(struct stu *stu,int n) +{ + int i,j; + struct stu t; + for(i=0;ic>(stu+j+1)->c)||((stu+j)->c==(stu+j+1)->c)&&((stu+j)->num>(stu+j+1)->num)) + { + t = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = t; + } + } + } + return; +} + +int main() +{ + struct stu g; + scanf("%s",&g.num); + scanf("%d",&g.c); + scanf("%s",&g.name); + scanf("%f",&g.m); + scanf("%f",&g.p); + scanf("%f",&g.e); + int i; + for(i=0;i<3;i++) + { + if(strcmp(stu[i].num,g.num)==0) + { + *(stu+i)=g; + } + } + min(stu,3); + for(i=0;i<3;i++) + { + if(i==0||stu[i].c!=stu[i-1].c) printf("%2d ",stu[i].c); + else printf(" "); + printf("%s %s %.1f %.1f %.1f",stu[i].num,stu[i].name,stu[i].m,stu[i].p,stu[i].e); + if(stu[i].x) printf(" modified"); + printf("\n"); + } + return 0; +}