From b7fa32510f9521a6e31567a0b8cfeb4dce4d17c3 Mon Sep 17 00:00:00 2001 From: p7cx2jokr <2160925370@qq.com> Date: Thu, 21 Nov 2024 11:09:09 +0800 Subject: [PATCH] ADD file via upload --- 3.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 3.c diff --git a/3.c b/3.c new file mode 100644 index 0000000..b533441 --- /dev/null +++ b/3.c @@ -0,0 +1,67 @@ +#include +struct student{ + int clas; + char id[20]; + double score1,score2,score3,total,aver; +}s[10]; + +void input(){ + int i,j; + for(i=0;i<3;i++){ + scanf("%s%lf%lf%lf",s[i].id,&s[i].score1,&s[i].score2,&s[i].score3); + s[i].total=s[i].score1+s[i].score2+s[i].score3; + s[i].aver=s[i].total/3; + } + for(i=0;i<2;i++){ + for(j=0;j<2;j++){ + if(s[j].total>s[j+1].total){ + struct student t; + t=s[j]; + s[j]=s[j+1]; + s[j+1]=t; + } + } + } + for(i=0;i<3;i++){ + printf("%s,%.1f,%.1f\n",s[i].id,s[i].total,s[i].aver); + } + +} + +int main(){ + char c; + while(1){ + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + scanf(" %c",&c); + if(c=='i'){ + printf("Please input info of the three students:\n"); + input(); + } + else if(c=='o') printf("You are trying to Output info\n"); + else if(c=='m') printf("You are trying to Make things ordered\n"); + else if(c=='q'){ + printf("You are about to Quit\n"); + break; + } + else printf("Wrong input\n"); + } + return 0; +} +//i +//10001 +//85.0 +//99.0 +//77.5 +//10002 +//88.5 +//88.5 +//90.0 +//10003 +//66.0 +//78.5 +//89.5 +//m +//q