From 7a46ce37b43e8eb423b45fb94f657554e80ec18d Mon Sep 17 00:00:00 2001 From: pvl836cjw <2745453479@qq.com> Date: Mon, 13 Nov 2023 20:32:11 +0800 Subject: [PATCH] ADD file via upload --- Task3.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Task3.c diff --git a/Task3.c b/Task3.c new file mode 100644 index 0000000..14fcb3a --- /dev/null +++ b/Task3.c @@ -0,0 +1,92 @@ + +#include +int main() +{ + int i; + for(i=30;i>=1;i--) printf(" "); + printf("1.Input\n"); + for(i=30;i>=1;i--) printf(" "); + printf("2.Output\n"); + for(i=30;i>=1;i--) printf(" "); + printf("3.Order\n"); + for(i=30;i>=1;i--) printf(" "); + printf("1.Quit\n"); + char x; + scanf("%c",&x); + switch(x) + { + case 'i':printf("Please input info of the three students:");break; + case 'm':printf("You are trying to Make tings Ordered");break; + case 'q':printf("You are about to Quit");break; + default:printf("Wrong Input"); + } + float sum=0,a[16]; + for(i=1;i<=12;i++) + { + scanf("%f",&a[i]); + } + for(i=1;i<=12;i++) + { + if(i!=1&&i!=5&&i!=9) + sum+=a[i]; + if(i%4==0) + { + a[12+i/4]=sum; + sum=0; + } + } + if(a[13]>=a[14]&&a[13]>=a[15]&&a[14]>=a[15]) + { + for(i=1;i<=12;i++) + { + if(i==1||i==5||i==9) + printf("%5.0f",a[i]); + else + { + if(i%4==0) + { + printf(",%0.1f",a[12+i/4]); + printf(",%0.1f",a[12+i/4]/3); + } + } + } + } + if(a[13]>=a[14]&&a[13]>=a[15]&&a[15]>=a[14]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + } + if(a[13]>=a[14]&&a[13]>=a[15]&&a[14]>=a[15]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + } + if(a[14]>=a[13]&&a[14]>=a[15]&&a[13]>=a[15]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + } + if(a[14]>=a[13]&&a[14]>=a[15]&&a[15]>=a[13]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + } + if(a[15]>=a[13]&&a[15]>=a[14]&&a[14]>=a[13]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + } + if(a[15]>=a[13]&&a[15]>=a[14]&&a[13]>=a[14]) + { + printf("%5.0f%,%0.1f,%0.1f\n",a[5],a[14],a[14]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[1],a[13],a[13]/3); + printf("%5.0f%,%0.1f,%0.1f\n",a[9],a[15],a[15]/3); + } + + +}