parent
b1fdc82907
commit
b7fa32510f
@ -0,0 +1,67 @@
|
||||
#include <stdio.h>
|
||||
struct student{
|
||||
int clas;
|
||||
char id[20];
|
||||
double score1,score2,score3,total,aver;
|
||||
}s[10];
|
||||
|
||||
void input(){
|
||||
int i,j;
|
||||
for(i=0;i<3;i++){
|
||||
scanf("%s%lf%lf%lf",s[i].id,&s[i].score1,&s[i].score2,&s[i].score3);
|
||||
s[i].total=s[i].score1+s[i].score2+s[i].score3;
|
||||
s[i].aver=s[i].total/3;
|
||||
}
|
||||
for(i=0;i<2;i++){
|
||||
for(j=0;j<2;j++){
|
||||
if(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<3;i++){
|
||||
printf("%s,%.1f,%.1f\n",s[i].id,s[i].total,s[i].aver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
char c;
|
||||
while(1){
|
||||
printf(" 1.Input\n");
|
||||
printf(" 2.Output\n");
|
||||
printf(" 3.Order\n");
|
||||
printf(" 4.Quit\n");
|
||||
scanf(" %c",&c);
|
||||
if(c=='i'){
|
||||
printf("Please input info of the three students:\n");
|
||||
input();
|
||||
}
|
||||
else if(c=='o') printf("You are trying to Output info\n");
|
||||
else if(c=='m') printf("You are trying to Make things ordered\n");
|
||||
else if(c=='q'){
|
||||
printf("You are about to Quit\n");
|
||||
break;
|
||||
}
|
||||
else printf("Wrong input\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//i
|
||||
//10001
|
||||
//85.0
|
||||
//99.0
|
||||
//77.5
|
||||
//10002
|
||||
//88.5
|
||||
//88.5
|
||||
//90.0
|
||||
//10003
|
||||
//66.0
|
||||
//78.5
|
||||
//89.5
|
||||
//m
|
||||
//q
|
Loading…
Reference in new issue