From f249bd3eb938b3eab4cc27a06ada9cd5a3e1cbba Mon Sep 17 00:00:00 2001 From: ph9kiql5e <157842898@qq.com> Date: Sun, 5 Nov 2023 10:29:36 +0800 Subject: [PATCH] ADD file via upload --- 3.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 3.c diff --git a/3.c b/3.c new file mode 100644 index 0000000..45b6e46 --- /dev/null +++ b/3.c @@ -0,0 +1,98 @@ +#include +int main() +{ + void manu(); + void log(); + manu(); + log(); + return 0; +} + +void manu() +{ + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + char t=getchar(); + if(t=='i') + { + printf("Please input info of the three students:\n"); + } + 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 + { + printf("Wrong input\n"); + } +} + +void log() +{ + float sum(float a[][5]); + void sort(float a[][5]); + float student[3][5]; + int i,j; + for(i=0;i<3;i++) + { + for(j=0;j<4;j++) + { + scanf("%f",&student[i][j]); + } + } + sum(student); + sort(student); + for(i=0;i<3;i++) + { + printf("%g,%4.1f,%4.1f\n",student[i][0],student[i][4],student[i][4]/3); + } +} + +float sum(float a[][5]) +{ + int i; + for(i=0;i<3;i++) + { + a[i][4]=a[i][1]+a[i][2]+a[i][3]; + } +} + +void sort(float a[][5]) +{ + void swap(float a[][5],int x,int y); + int i,j,k; + for(i=0;i<3;i++) + { + k=i; + for(j=i;j<3;j++) + { + if(a[i][4]>a[j][4]) + { + k=j; + } + } + swap(a,i,k); + } +} + +void swap(float a[][5],int x,int y) +{ + int i; + float temp; + for(i=0;i<5;i++) + { + temp=a[x][i]; + a[x][i]=a[y][i]; + a[y][i]=temp; + } +}