From e24e5f98eaa6d44dbb17a82be3b054a9a77b5f90 Mon Sep 17 00:00:00 2001 From: psc4a9qur Date: Fri, 22 Nov 2024 18:22:26 +0800 Subject: [PATCH] ADD file via upload --- a3.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 a3.c diff --git a/a3.c b/a3.c new file mode 100644 index 0000000..481e82f --- /dev/null +++ b/a3.c @@ -0,0 +1,62 @@ +#include +struct stu { + int num; + float grade1; + float grade2; + float grade3; + float grade; + float ag; +}s[10],ss; + +int main() +{ + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + char a; + scanf("%c",&a); + if(a=='i') + { + + + printf("Please input info of the three students:\n"); + for(int i=0;i<3;i++) + { + scanf("%d%f%f%f",&s[i].num,&s[i].grade1,&s[i].grade2,&s[i].grade3); + } + for(int i=0;i<3;i++) + { + s[i].grade=s[i].grade1+s[i].grade2+s[i].grade3; + s[i].ag=s[i].grade/3; + } + for(int i=0;i<2;i++) + { + ss=s[i]; + for(int j=i+1;j<3;j++) + { + if(s[i].grade>s[j].grade) + { + ss=s[i]; + s[i]=s[j]; + s[j]=ss; + } + + } + } + for(int i=0;i<3;i++) + { + printf("%d,%.1f,%.1f\n",s[i].num,s[i].grade,s[i].ag); + } + } + else if(a=='o') + printf("You are trying to Output info"); + else if(a=='m') + printf("You are trying to Make things ordered"); + else if(a=='q') + printf("You are about to Quit"); + else + printf("Wrong input"); + + return 0; +} \ No newline at end of file