From 49de8bde63f9e87ba533408da3d288b6193d5627 Mon Sep 17 00:00:00 2001 From: phf9mvrip <2592369015@qq.com> Date: Sat, 11 Nov 2023 22:40:23 +0800 Subject: [PATCH] ADD file via upload --- T7.inquire.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 T7.inquire.cpp diff --git a/T7.inquire.cpp b/T7.inquire.cpp new file mode 100644 index 0000000..690ccc9 --- /dev/null +++ b/T7.inquire.cpp @@ -0,0 +1,133 @@ +#include +#include +struct stud + { + int num; + int clas; + char name[10]; + float math; + float phy; + float eng; + }t={}; +int main() +{ + struct stud stu[10]={{10001,11,"Zhang",99.5,88.5,89.5}, + {10002,12,"Yang",77.9,56.5,87.5}, + {10003,11,"Liang",92.5,99.0,60.}, + {10004,11,"Cai",89.6,56.9,90.5}, + {10005,14,"Fu",55.6,67.9,98.9}, + {10006,12,"Mao",22.1,45.9,99.2}, + {10007,13,"Zhan",35.6,67.9,88.0} + }; + struct stud *p=stu; + void range(struct stud stu[]); + range(p); + void getclass(struct stud stu[]); + void getnum(struct stud stu[]); + void getname(struct stud stu[]); + void getgrade(struct stud stu[]); + void getclnum(struct stud stu[]); + int way; + scanf("%d",&way); + switch(way) + { + case 1:getclass(p);break; + case 2:getnum(p);break; + case 3:getname(p);break; + case 4:getgrade(p);break; + case 5:getclnum(p);break; + + } + return 0; +} +void range(struct stud stu[]) +{ + int i,j; + for(i=0;stu[i].num!=0;i++) + { + if(stu[i+1].num!=0) + { + for(j=i+1;stu[j].num!=0;j++) + { + if(stu[i].clas>stu[j].clas) + { + t=stu[i];stu[i]=stu[j];stu[j]=t; + } + } + } + } + for(i=0;stu[i].num!=0;i++) + { + if(stu[i+1].num!=0) + { + for(j=i+1;stu[j].num!=0&&stu[i].clas==stu[j].clas;j++) + { + if(stu[i].math+stu[i].phy+stu[i].eng=a) + printf("%d %d %s %3.1f %3.1f %3.1f\n",stu[i].num,stu[i].clas,stu[i].name,stu[i].math,stu[i].phy,stu[i].eng); + } +} +void getclnum(struct stud stu[]) +{ + int a,b,c,i; + char x,xx; + scanf("%d %c %d %c %d",&a,&x,&b,&xx,&c); + for(i=0;stu[i].num!=0;i++) + { + if(b<=stu[i].num&&stu[i].num<=c&&stu[i].clas==a) + printf("%d %d %s %3.1f %3.1f %3.1f\n",stu[i].num,stu[i].clas,stu[i].name,stu[i].math,stu[i].phy,stu[i].eng); + } +} +