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.
137 lines
2.6 KiB
137 lines
2.6 KiB
#include <stdio.h>
|
|
#include <string.h>
|
|
int cnt=0;
|
|
struct student{
|
|
int clas;
|
|
char id[20],name[20];
|
|
double score1,score2,score3,total;
|
|
}s[10];
|
|
|
|
void input(){
|
|
int i,j;
|
|
for(i=0;i<7;i++){
|
|
scanf("%s%d%s%lf%lf%lf",s[i].id,&s[i].clas,s[i].name,&s[i].score1,&s[i].score2,&s[i].score3);
|
|
cnt++;
|
|
s[i].total=s[i].score1+s[i].score2+s[i].score3;
|
|
}
|
|
|
|
}
|
|
|
|
void select(){
|
|
int n,i,j;
|
|
scanf("%d",&n);
|
|
if(n==1){
|
|
int clas1,clas2;
|
|
scanf("%d-%d",&clas1,&clas2);
|
|
for(i=0;i<cnt;i++){
|
|
if(s[i].clas>=clas1&&s[i].clas<=clas2){
|
|
output(i);
|
|
}
|
|
}
|
|
}
|
|
else if(n==2){
|
|
char range[40],id1[20],id2[20]={};
|
|
scanf("%s",range);
|
|
for(i=0;i<strlen(range);i++){
|
|
if(range[i]=='-'){
|
|
strncpy(id1,range,i);
|
|
int t=0;
|
|
for(i++;i<strlen(range);i++){
|
|
id2[t++]=range[i];
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
for(i=0;i<cnt;i++){
|
|
if(strcmp(s[i].id,id1)>=0&&strcmp(s[i].id,id2)<=0){
|
|
output(i);
|
|
}
|
|
}
|
|
}
|
|
else if(n==3){
|
|
char capital[20];
|
|
scanf("%s",capital);
|
|
for(i=0;i<cnt;i++){
|
|
int flag=1;
|
|
for(j=0;j<strlen(capital)-1;j++){
|
|
if(s[i].name[j]!=capital[j]){
|
|
flag=0;
|
|
break;
|
|
}
|
|
}
|
|
if(flag) output(i);
|
|
}
|
|
}
|
|
else if(n==4){
|
|
double score;
|
|
scanf("%lf",&score);
|
|
for(i=0;i<cnt;i++){
|
|
if(s[i].total>=score) output(i);
|
|
}
|
|
}
|
|
else if(n==5){
|
|
int clas;
|
|
char range[40],id1[20]={},id2[20]={};
|
|
scanf("%s",range);
|
|
clas=10*(range[0]-'0')+range[1]-'0';
|
|
for(i=0;i<strlen(range);i++){
|
|
if(range[i]=='.'){
|
|
int t=0;
|
|
for(i++;i<strlen(range);i++){
|
|
if(range[i]=='-') break;
|
|
id1[t++]=range[i];
|
|
}
|
|
t=0;
|
|
for(i++;i<strlen(range);i++){
|
|
id2[t++]=range[i];
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
for(i=0;i<cnt;i++){
|
|
if(s[i].clas==clas&&strcmp(s[i].id,id1)>=0&&strcmp(s[i].id,id2)<=0){
|
|
output(i);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void order(){
|
|
int i,j;
|
|
for(i=0;i<cnt-1;i++){
|
|
for(j=0;j<cnt-i-1;j++){
|
|
if(s[j].clas>s[j+1].clas||(s[j].clas==s[j+1].clas&&s[j].total<s[j+1].total)){
|
|
struct student t;
|
|
t=s[j];
|
|
s[j]=s[j+1];
|
|
s[j+1]=t;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void output(int i){
|
|
printf("%s %d %s %.1f %.1f %.1f\n",s[i].id,s[i].clas,s[i].name,s[i].score1,s[i].score2,s[i].score3);
|
|
}
|
|
|
|
int main(){
|
|
input();
|
|
order();
|
|
int i;
|
|
for(i=1;i<=5;i++) select();
|
|
return 0;
|
|
}
|
|
//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
|
|
//1 11-13
|
|
//2 10001-10004
|
|
//3 Zh*
|
|
//4 98.0
|
|
//5 11.10001-10004
|