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.
49 lines
1.0 KiB
49 lines
1.0 KiB
1 day ago
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
struct student{
|
||
|
int clas,inserted;
|
||
|
char id[20];
|
||
|
double score1,score2,score3,total;
|
||
|
}s[10];
|
||
|
|
||
|
void input(){
|
||
|
int i,j,cnt=0;
|
||
|
for(i=0;i<4;i++){
|
||
|
scanf("%s%d%lf%lf%lf",s[i].id,&s[i].clas,&s[i].score1,&s[i].score2,&s[i].score3);
|
||
|
cnt++;
|
||
|
if(i!=3) s[i].inserted=0;
|
||
|
else s[i].inserted=1;
|
||
|
for(j=0;j<i;j++){
|
||
|
if(strcmp(s[i].id,s[j].id)==0){
|
||
|
cnt--;
|
||
|
}
|
||
|
}
|
||
|
s[i].total=s[i].score1+s[i].score2+s[i].score3;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
for(i=0;i<cnt;i++){
|
||
|
printf("%s %d %.1f %.1f %.1f",s[i].id,s[i].clas,s[i].score1,s[i].score2,s[i].score3);
|
||
|
if(s[i].inserted==1) printf(" inserted");
|
||
|
printf("\n");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
input();
|
||
|
return 0;
|
||
|
}
|
||
|
//10001 11 99.5 88.5 89.5
|
||
|
//10002 12 77.9 56.5 87.5
|
||
|
//10003 11 92.5 99.0 60.5
|
||
|
//1004 11 23.4 45.6 99.0
|