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.

72 lines
1.8 KiB

#include <stdio.h>
#include <ctype.h>
int main() {
char choice;
printf(" 1.Input\n 2.Output\n 3.Order\n 4.Quit\n", "", "", "", "");
choice='i';
printf("i");
printf("\n");
switch (choice) {
case 'i':
printf("Please input info of the three stdents:\n");
int s[3];
float m[3],w[3],e[3],t[3],a[3];
s[0] = 10001;
m[0] = 85.0;
w[0] = 99.0;
e[0] = 77.5;
s[1] = 10002;
m[1] = 88.5;
w[1] = 88.5;
e[1] = 90.0;
s[2] = 10003;
m[2] = 66.0;
w[2] = 78.5;
e[2] = 89.5;
for(int i=0;i<3;i++)
{
t[i] = m[i] + w[i]+ e[i];
a[i] = t[i] / 3.0;
}
for(int p=0;p<2;p++)
{for(int j=0;j<2-p;j++)
{if(t[j]>t[j+1])
{float m=t[j];
t[j]=t[j+1];
t[j+1]=m;
float n=a[j];
a[j]=a[j+1];
a[j+1]=n;
int k=s[j];
s[j]=s[j+1];
s[j+1]=k;
}
}
}
for(int i=0;i<3;i++)
{printf("%d %.1f %.1f\n",s[i],t[i],a[i]);
}
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");
return 0;
default:
printf("Wrong input\n");
}
return 0;
}