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.
77 lines
1.5 KiB
77 lines
1.5 KiB
3 days ago
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
int cnt=0;
|
||
|
struct student{
|
||
|
int clas,modified;
|
||
|
char id[20],name[20];
|
||
|
double score1,score2,score3,total;
|
||
|
}s[10];
|
||
|
|
||
|
void input(){
|
||
|
int i,j;
|
||
|
for(i=0;i<3;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);
|
||
|
s[i].modified=0;
|
||
|
cnt++;
|
||
|
s[i].total=s[i].score1+s[i].score2+s[i].score3;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void modify(){
|
||
|
char str[20];
|
||
|
scanf("%s",str);
|
||
|
int i=find(str);
|
||
|
if(i!=-1){
|
||
|
scanf("%d%s%lf%lf%lf",&s[i].clas,s[i].name,&s[i].score1,&s[i].score2,&s[i].score3);
|
||
|
s[i].total=s[i].score1+s[i].score2+s[i].score3;
|
||
|
s[i].modified=1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int find(char str[]){
|
||
|
int i;
|
||
|
for(i=0;i<cnt;i++){
|
||
|
if(strcmp(s[i].id,str)==0||strcmp(s[i].name,str)==0){
|
||
|
return i;
|
||
|
}
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
for(i=0;i<cnt;i++){
|
||
|
if(i==0||s[i].clas!=s[i-1].clas) printf("%d ",s[i].clas);
|
||
|
else printf(" ");
|
||
|
printf("%s %s %.1f %.1f %.1f",s[i].id,s[i].name,s[i].score1,s[i].score2,s[i].score3);
|
||
|
if(s[i].modified==1) printf(" modified");
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
input();
|
||
|
modify();
|
||
|
order();
|
||
|
output();
|
||
|
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
|
||
|
//10001 11 Zhang 99 88 89
|