From cebbc7dc54b3e033ba7b2e745666324599e5deb6 Mon Sep 17 00:00:00 2001 From: psc4a9qur Date: Fri, 22 Nov 2024 18:21:50 +0800 Subject: [PATCH] ADD file via upload --- a7.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 a7.c diff --git a/a7.c b/a7.c new file mode 100644 index 0000000..0995b76 --- /dev/null +++ b/a7.c @@ -0,0 +1,152 @@ +#include +#include +struct stu { + char num[6]; + char class[3]; + char name[6]; + float grade1; + float grade2; + float grade3; + float grade; +}s[10],ss,sss[7]; +void f1(struct stu s[],int k) +{ + for(int i=0;i0) + { + ss=s[i]; + s[i]=s[j]; + s[j]=ss; + } + } + } +} +void f2(struct stu s[]) +{ + for(int o=11;o<=14;o++) + { + for(int i=0;s[i].class==o;i++) + { + for(int j=i+1;s[j].class==o;j++) + { + if(s[i].grade=0&&strcmp(s[i].class,bb)<=0) + { + sss[k]=s[i]; + k++; + } + } + f1(sss,k); + f2(sss); + f3(sss,k); + } + else if(a==2) + { + char cc[6],dd[6]; + scanf("%s %s",cc,dd); + int k=0; + for(int i=0;i<7;i++) + { + if(strcmp(s[i].num,cc)>=0&&strcmp(s[i].num,dd)<=0) + { + sss[k]=s[i]; + k++; + } + } + f1(sss,k); + f2(sss); + f3(sss,k); + } + else if(a==3) + { + char hh[10]; + scanf("%s",hh); + int len=strlen(hh); + int k=0; + for(int i=0;i<7;i++) + { + if(strncmp(hh,s[i].name,len-1)==0) + { + sss[k]=s[i]; + k++; + } + } + f1(sss,k); + f2(sss); + f3(sss,k); + } + else if(a==4) + { + double d; + scanf("%lf",&d); + int k=0; + for(int i=0;i<7;i++) + { + if(s[i].grade>=d) + { + sss[k]=s[i]; + k++; + } + } + f1(sss,k); + f2(sss); + f3(sss,k); + } + + else if(a==5) + { + char ee[3],ff[6],gg[6]; + scanf("%s%s%s",ee,ff,gg); + int k=0; + for(int i=0;i<7;i++) + { + if(strcmp(s[i].class,ee)==0&&strcmp(s[i].num,ff)>=0&&strcmp(s[i].num,gg)<=0) + { + sss[k]=s[i]; + k++; + } + } + f1(sss,k); + f2(sss); + f3(sss,k); + } + return 0; +} \ No newline at end of file