From c783094bada81e4c7117cd1ad36cc1580d0bcae9 Mon Sep 17 00:00:00 2001 From: pvkyt5ngb Date: Fri, 10 Nov 2023 12:27:20 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E6=AD=A5=E9=AA=A4=E4=B8=83.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 步骤七.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 步骤七.c diff --git a/步骤七.c b/步骤七.c new file mode 100644 index 0000000..8fa4f2a --- /dev/null +++ b/步骤七.c @@ -0,0 +1,133 @@ +#include +#include +struct data +{ + long int num; + long int clas; + char name[20]; + float grade1; + float grade2; + float grade3; +}; +struct data stu[7]={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.5, +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 data stud; +int main() +{ + void sort(); + void print(struct data a); + sort(); + int t; + scanf("%d",&t); + if(t==1) + { + printf("请输入 班级-班级\n"); + int clas1,clas2; + scanf("%ld-%ld",&clas1,&clas2); + for(int i=0;i<7;i++) + { + if(stu[i].clas>=clas1&&stu[i].clas<=clas2) + { + print(stu[i]); + printf("\n");} + } + } + if(t==2) + { + int num1,num2; + printf("请输入 学号-学号\n"); + scanf("%ld-%ld",&num1,&num2); + for(int i=0;i<7;i++) + { + if(stu[i].num>=num1&&stu[i].num<=num2) + { + print(stu[i]); + printf("\n");} + } + } + if(t==3) + { + printf("请输入要查询的人名开头几个字母\n"); + char nam[10];int len; + scanf("%s",nam); + len=strlen(nam); + for(int i=0;i<7;i++) + { + int k=1; + for(int j=0;j=score) + { + print(stu[i]); + printf("\n");} + } + } + if(t==5) + { + printf("请输入 班级.学号-学号\n"); + int cla,nu1,nu2; + scanf("%ld.%ld-%ld",&cla,&nu1,&nu2); + for(int i=0;i<7;i++) + { + if(stu[i].clas==cla&&stu[i].num>=nu1&&stu[i].num<=nu2) + { + print(stu[i]); + printf("\n"); + } + } + } + + } + void sort() + { + struct data temp; + for(int i=0;i<7;i++) + { + for(int j=i+1;j<7;j++) + { + if(stu[i].clas>stu[j].clas) + { + temp=stu[i]; + stu[i]=stu[j]; + stu[j]=temp; + } + } + } + for(int i=0;i<7;i++) + { + for(int j=i+1;j<7;j++) + { + if(stu[i].num>stu[j].num&&stu[i].clas==stu[j].clas) + { + temp=stu[i]; + stu[i]=stu[j]; + stu[j]=temp; + } + } + } + } + void print(struct data a) + { + printf("%ld %ld %s %3.1f %3.1f %3.1f",a.num,a.clas,a.name,a.grade1,a.grade2,a.grade3); + } \ No newline at end of file