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.

76 lines
1.2 KiB

#include<stdio.h>
struct stu
{
int num;
float m,p,e,s,a;
};
struct stu stu[3];
void min(struct stu *stu)
{
int i,j;
struct stu t;
for(i=0;i<3;i++)
{
for(j=0;j<2-i;j++)
{
if((stu+j)->a>(stu+j+1)->a)
{
t= *(stu+j);
*(stu+j) = *(stu+j+1);
*(stu+j+1) = t;
}
}
}
return;
}
void dd(void)
{
int i;
for(i=0;i<3;i++)
{
scanf("%d",&stu[i].num);
scanf("%f",&stu[i].m);
scanf("%f",&stu[i].p);
scanf("%f",&stu[i].e);
stu[i].s=stu[i].m+stu[i].p+stu[i].e;
stu[i].a=stu[i].s/3;
}
min(stu);
for(i=0;i<3;i++)
{
printf("%d,%.1f,%.1f\n",stu[i].num,stu[i].s,stu[i].a);
}
return;
}
int main()
{
char input;
printf(" 1.Input\n");
printf(" 2.Output\n");
printf(" 3.Order\n");
printf(" 4.Quit\n");
scanf("%c",&input);
switch(input)
{
case('i'):
dd();
break;
case('o'):
printf("You are trying to Output info\n");
break;
case('m'):
printf("You are trying to Make things ordered\n");
break;
case('q'):
printf("You are about to Quit\n");
break;
default:
printf("Wrong input");
}
return 0;
}