ADD file via upload

main
p7cx2jokr 10 hours ago
parent f0d7a48cd4
commit 467dc8ad70

79
5.c

@ -0,0 +1,79 @@
//´Ó´ËÌ⿪ʼ·â×°º¯Êý
#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<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);
cnt++;
s[i].total=s[i].score1+s[i].score2+s[i].score3;
}
}
void del(){
char str[20];
scanf("%s",str);
int i=find(str);
if(i!=-1){
for(;i<cnt;i++){
s[i]=s[i+1];
}
cnt--;
}
}
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++){
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();
del();
order();
printf("Are you sure(yes/no)?");
char c;
scanf(" %c",&c);
if(c=='n') 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
//Zhang
//n
Loading…
Cancel
Save