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.
112 lines
2.1 KiB
112 lines
2.1 KiB
#include<stdio.h>
|
|
#include<string.h>
|
|
struct stu
|
|
{
|
|
int num,c;
|
|
char name[20];
|
|
float m,p,e;
|
|
};
|
|
|
|
struct stu 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}};
|
|
|
|
|
|
void a1()
|
|
{int to,from,i;
|
|
scanf("%d-%d",&from,&to);
|
|
for(i=0;i<7;i++) if(from<=stu[i].c&&stu[i].c<=to) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
|
|
}
|
|
|
|
void a2()
|
|
{int to,from,i;
|
|
scanf("%d-%d",&from,&to);
|
|
for(i=0;i<7;i++) if(to<=stu[i].num&&stu[i].num<=from) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
|
|
}
|
|
|
|
void a3()
|
|
{
|
|
int i,j;
|
|
char n[20];
|
|
scanf("%s",n);
|
|
for(i=0;i<7;i++)
|
|
{
|
|
j=0;
|
|
while(n[j]!='*'&&stu[i].name[j]==n[j]) j++;
|
|
if(n[j]=='*') printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
|
|
}
|
|
}
|
|
|
|
void a4()
|
|
{
|
|
int i;
|
|
float lim,s;
|
|
scanf("%d",&lim);
|
|
for(i=0;i<7;i++)
|
|
{
|
|
s=stu[i].m+stu[i].p+stu[i].e;
|
|
if(s>=lim) printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
|
|
}
|
|
}
|
|
|
|
void a5()
|
|
{
|
|
int cl,to,from,i;
|
|
scanf("%d.%d-%d",&cl,&from,&to);
|
|
for(i=0;i<7;i++)
|
|
{
|
|
if(stu[i].c==cl&&from<=stu[i].num&&stu[i].num<=to)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[i].num,stu[i].c,stu[i].name,stu[i].m,stu[i].p,stu[i].e);
|
|
}
|
|
}
|
|
}
|
|
void min(struct stu *stu,int n)
|
|
{
|
|
int i,j;
|
|
struct stu t;
|
|
for(i=0;i<n;i++)
|
|
{
|
|
for(j=0;j<n-i-1;j++)
|
|
{
|
|
if(((stu+j)->c>(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()
|
|
{
|
|
int n;
|
|
scanf("%d",&n);
|
|
min(stu,7);
|
|
switch(n)
|
|
{
|
|
case(1):
|
|
a1();
|
|
break;
|
|
case(2):
|
|
a2();
|
|
break;
|
|
case(3):
|
|
a3();
|
|
break;
|
|
case(4):
|
|
a4();
|
|
break;
|
|
case(5):
|
|
a5();
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|