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.

98 lines
1.6 KiB

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
void input();
void order();
void output();
void menu();
int sum=0;
struct stu
{
int Id;
float score1;
float score2;
float score3;
float score;
float arvscore;
}stu[1000];
int main()
{
while(1)
{
menu();
}
}
void menu()
{
char t;
printf(" 1.Input\n");
printf(" 2.output\n");
printf(" 3.order\n");
printf(" 4.quit\n");
t=getchar();
if(t=='i')
{
printf("Please input info of the three students:\n");
for(int i=0;i<3;i++)
{
input();
}
order();
output();
exit(0);
}
else if(t=='o')
{
printf("You are trying to Output info\n");
}
else if(t=='m')
{
printf("You are trying to Make things ordered\n");
}
else if(t=='q')
{
printf("You are about to Quit\n");
}
else
{
if(t!='\n')
{
printf("Wrong input\n");
}
}
}
void input()
{
sum=sum+1;
scanf("%d",&stu[sum].Id);
scanf("%f",&stu[sum].score1);
scanf("%f",&stu[sum].score2);
scanf("%f",&stu[sum].score3);
stu[sum].score=stu[sum].score3+stu[sum].score2+stu[sum].score1;
stu[sum].arvscore=stu[sum].score/3;
}
void order()
{
for(int i=1;i<=sum;i++)
{
for(int j=i;j<=sum;j++)
{
if(stu[i].score>stu[j].score)
{
stu[sum+1]=stu[i];
stu[i]=stu[j];
stu[j]=stu[sum+1];
}
}
}
}
void output()
{
for(int i=1;i<=sum;i++)
{
printf("%d %.1f %.1f\n",stu[i].Id,stu[i].score,stu[i].arvscore);
}
}