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.

61 lines
1.2 KiB

#include <stdio.h>
int main()
{
printf(" 1.Input\n 2.Output\n 3.Order\n 4.Quit\n");
char a;
for(;;)
{
a=getchar();
switch(a)
{
case'i': printf("Please input info of the three students:\n");
struct Student
{
int n;
float x;
float y;
float z;
float s;
float w;
};
int i,j,k;
struct Student stu[3],t;
for(i=0;i<3;i++)
{
scanf("%d%f%f%f",&stu[i].n,&stu[i].x,&stu[i].y,&stu[i].z);
}
stu[0].s=stu[0].x+stu[0].y+stu[0].z;
stu[1].s=stu[1].x+stu[1].y+stu[1].z;
stu[2].s=stu[2].x+stu[2].y+stu[2].z;
stu[0].w=stu[0].s/3;
stu[1].w=stu[1].s/3;
stu[2].w=stu[2].s/3;
for(i=0;i<2;i++)
{
k=i;
for(j=i+1;j<3;j++)
{
if(stu[k].w<stu[j].w)
k=j;
}
t=stu[k];stu[k]=stu[i];stu[i]=t;
}
for(j=0;j<3;j++)
{
printf("ѧºÅ %d ×ܳɼ¨ %.1f ƽ¾ù³É¼¨ %.1f\n",stu[j].n,stu[j].s,stu[j].w);
}
break;
case'm': printf("You are trying to Make things ordered");break;
case'q': printf("You are about to Quit");break;
case'\n': printf("\n");break;
default: printf("Wrong input");
}
}
}