You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.3 KiB
116 lines
2.3 KiB
1 year ago
|
#include<stdio.h>
|
||
|
#include<string.h>
|
||
|
#define N 7
|
||
|
|
||
|
struct stu_info
|
||
|
{
|
||
|
int num,cls;
|
||
|
char name[20];
|
||
|
float math,physics,english;
|
||
|
};
|
||
|
|
||
|
struct stu_info stu[N]={{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}};
|
||
|
|
||
|
void sort(struct stu_info *stu,int n)
|
||
|
{
|
||
|
int i,j;
|
||
|
struct stu_info tmp;
|
||
|
for(i=0;i<n;i++)
|
||
|
{
|
||
|
for(j=0;j<n-i-1;j++)
|
||
|
{
|
||
|
if(((stu+j)->cls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num))
|
||
|
{
|
||
|
tmp = *(stu+j);
|
||
|
*(stu+j) = *(stu+j+1);
|
||
|
*(stu+j+1) = tmp;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void s_cls()
|
||
|
{
|
||
|
int to,from,i;
|
||
|
scanf("%d-%d",&to,&from);
|
||
|
for(i=0;i<N;i++) if(to<=stu[i].cls&&stu[i].cls<=from) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
}
|
||
|
|
||
|
void s_num()
|
||
|
{
|
||
|
int to,from,i;
|
||
|
scanf("%d-%d",&to,&from);
|
||
|
for(i=0;i<N;i++) if(to<=stu[i].num&&stu[i].num<=from) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
}
|
||
|
|
||
|
void s_name()
|
||
|
{
|
||
|
int i,j;
|
||
|
char key[20];
|
||
|
scanf("%s",key);
|
||
|
for(i=0;i<N;i++)
|
||
|
{
|
||
|
j=0;
|
||
|
while(key[j]!='*'&&stu[i].name[j]==key[j]) j++;
|
||
|
if(key[j]=='*') printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void s_total()
|
||
|
{
|
||
|
int i;
|
||
|
float lim,total;
|
||
|
scanf("%d",&lim);
|
||
|
for(i=0;i<N;i++)
|
||
|
{
|
||
|
total=stu[i].math+stu[i].physics+stu[i].english;
|
||
|
if(total>=lim) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void s_cls_num()
|
||
|
{
|
||
|
int key,to,from,i;
|
||
|
scanf("%d.%d-%d",&key,&to,&from);
|
||
|
for(i=0;i<N;i++)
|
||
|
{
|
||
|
if(stu[i].cls==key&&to<=stu[i].num&&stu[i].num<=from)
|
||
|
{
|
||
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int op;
|
||
|
scanf("%d",&op);
|
||
|
sort(stu,N);
|
||
|
switch(op)
|
||
|
{
|
||
|
case(1):
|
||
|
s_cls();
|
||
|
break;
|
||
|
case(2):
|
||
|
s_num();
|
||
|
break;
|
||
|
case(3):
|
||
|
s_name();
|
||
|
break;
|
||
|
case(4):
|
||
|
s_total();
|
||
|
break;
|
||
|
case(5):
|
||
|
s_cls_num();
|
||
|
break;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|