From a14fb882ae6281428a7f32340b0ea06dc2e0c041 Mon Sep 17 00:00:00 2001 From: pk6gv5h38 <2932140327@qq.com> Date: Sun, 5 Nov 2023 12:16:09 +0800 Subject: [PATCH] ADD file via upload --- 作业2.3.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 作业2.3.c diff --git a/作业2.3.c b/作业2.3.c new file mode 100644 index 0000000..9a360d6 --- /dev/null +++ b/作业2.3.c @@ -0,0 +1,41 @@ +#include +int main() +{struct Student + { + int num; + float score1; + float score2; + float score3; + float all; + float aver; + }student1,student2,student3; + char c; + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + c=getchar(); + switch(c) + { + case 'i':printf("Please input info of the three students:\n"); + scanf("%d%f%f%f",&student1.num,&student1.score1,&student1.score2,&student1.score3); + scanf("%d%f%f%f",&student2.num,&student2.score1,&student2.score2,&student2.score3); + scanf("%d%f%f%f",&student3.num,&student3.score1,&student3.score2,&student3.score3); + student1.all = student1.score1 + student1.score2 + student1.score3; + student1.aver=student1.all/3; + student2.all = student2.score1 + student2.score2 + student2.score3; + student2.aver=student2.all/3; + student3.all = student3.score1 + student3.score2 + student3.score3; + student3.aver=student3.all/3; + printf("%d %.1f %.1f\n",student3.num,student3.all,student3.aver); + printf("%d %.1f %.1f\n",student1.num,student1.all,student1.aver); + printf("%d %.1f %.1f\n",student2.num,student2.all,student2.aver); + + break; + case 'o':printf("You are trying to Output info");break; + case 'm':printf("You are trying to Make things ordered");break; + case 'q':printf("You are about to Quit");break; + default:printf("Wrong input");break; + } +} +