|
|
|
@ -0,0 +1,55 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
struct Student
|
|
|
|
|
{
|
|
|
|
|
int id;
|
|
|
|
|
float gs;
|
|
|
|
|
float dw;
|
|
|
|
|
float yy;
|
|
|
|
|
float sum;
|
|
|
|
|
float aver;
|
|
|
|
|
}stu[3],temp;
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
printf(" 1.Input\n");
|
|
|
|
|
printf(" 2.Output\n");
|
|
|
|
|
printf(" 3.Order\n");
|
|
|
|
|
printf(" 4.Quit\n");
|
|
|
|
|
int i=0,j=0;
|
|
|
|
|
char x;
|
|
|
|
|
scanf("%c",&x);
|
|
|
|
|
switch(x){
|
|
|
|
|
case 'o':printf("You are trying to Output info");break;
|
|
|
|
|
case 'm':printf("You are trying to Make things ordered");break;
|
|
|
|
|
case 'q':printf("You are about to Quit");break;
|
|
|
|
|
case 'i':printf("Please input info of the three students:\n");
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
|
{
|
|
|
|
|
scanf("%d\n",&stu[i].id);
|
|
|
|
|
scanf("%f\n",&stu[i].gs);
|
|
|
|
|
scanf("%f\n",&stu[i].dw);
|
|
|
|
|
scanf("%f\n",&stu[i].yy);
|
|
|
|
|
stu[i].sum=stu[i].gs+stu[i].dw+stu[i].yy;
|
|
|
|
|
stu[i].aver=stu[i].sum/3;
|
|
|
|
|
}
|
|
|
|
|
for( i=0;i<3;i++)//排序操作
|
|
|
|
|
{
|
|
|
|
|
for( j=0;j<3-i-1;j++)
|
|
|
|
|
{
|
|
|
|
|
if(stu[j].sum>stu[j+1].sum)
|
|
|
|
|
{
|
|
|
|
|
temp=*(stu+j);
|
|
|
|
|
*(stu+j)=*(stu+j+1);
|
|
|
|
|
*(stu+j+1)=temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("学号 %d,总成绩 %.1f,平均成绩 %.1f\n",stu[i].id,stu[i].sum,stu[i].aver);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:printf("Wrong input\n");break;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|