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.

71 lines
1.2 KiB

#include <stdio.h>
struct s {
int num;
float m;
float p;
float e;
float s;
float a;
};
void scan()
{
struct s stu[3];
int i,j;
float sum;
for(i=0;i<3;i++)
{
scanf("%d %f %f %f",&stu[i].num,&stu[i].m,&stu[i].p,&stu[i].e);
stu[i].s=stu[i].m+stu[i].p+stu[i].e;
stu[i].a=stu[i].s/3.0;
}
struct s temp;
for(i=0;i<3;i++)
{
int k=i;
for(j=i;j<3;j++)
{
if(stu[k].s>stu[j].s)
{
temp=stu[j];
stu[j]=stu[k];
stu[k]=temp;
}
}
}
for(i=0;i<3;i++)
{
printf("%d %d,%.1f %d,%.1f %d\n",stu[i].num,i+1,stu[i].s,i+1,stu[i].a,i+1);
}
}
void main()
{
printf("%*s%s\n",30,"","1.Input" );
printf("%*s%s\n",30,"","2.Output" );
printf("%*s%s\n",30,"","3.Order" );
printf("%*s%s\n",30,"","4.Quit" );
char ch;
scanf("%s",&ch);
printf("\n");
if(ch=='i')
{
printf("Please input info of the three students:");
scan();
}else{
if(ch=='o'){
printf("You are trying to Output info");
}else{
if(ch=='m'){
printf("You are trying to Make things ordered");
}else{
if(ch=='q'){
printf("You are about to Quit");
}else{
printf("Wrong input");
}
}
}
}
}