From d190c9ba840b73db014025002a8cc8b78acd8fe4 Mon Sep 17 00:00:00 2001 From: ph9kiql5e <157842898@qq.com> Date: Sun, 5 Nov 2023 10:29:43 +0800 Subject: [PATCH] ADD file via upload --- 4.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 4.c diff --git a/4.c b/4.c new file mode 100644 index 0000000..78f3dea --- /dev/null +++ b/4.c @@ -0,0 +1,151 @@ +#include +int s=3; +int main() +{ + void log(); + log(); + return 0; +} + +void log() +{ + float sum(float a[][6]); + void sort(float a[][6]); + float student[4][6]; + int i,j; + student[0][0]=10001; + student[0][1]=11; + student[0][2]=99.5; + student[0][3]=88.5; + student[0][4]=89.5; + student[1][0]=10002; + student[1][1]=12; + student[1][2]=77.9; + student[1][3]=56.5; + student[1][4]=87.5; + student[2][0]=10003; + student[2][1]=11; + student[2][2]=92.5; + student[2][3]=99.5; + student[2][4]=60.5; + for(j=0;j<5;j++) + { + scanf("%f",&student[3][j]); + } + sum(student); + sort(student); + for(i=0;i<4;i++) + { + for(j=0;j<5;j++) + { + if(j<2) + { + printf("%g",student[i][j]); + } + else + { + printf("%4.1f",student[i][j]); + } + if(j==4) + { + if(i==s) + { + printf(" inserted"); + } + printf("\n"); + } + else + { + printf(" "); + } + } + } +} + +float sum(float a[][6]) +{ + int i; + for(i=0;i<4;i++) + { + a[i][5]=a[i][2]+a[i][3]+a[i][4]; + } +} + +void sort(float a[][6]) +{ + void swap(float a[][6],int x,int y); + void sort2(float a[][6],int n,int m); + int i,j,k; + int min; + for(i=0;i<4;i++) + { + min=a[i][1]; + k=i; + for(j=i;j<4;j++) + { + if(min>a[j][1]) + { + min=a[j][1]; + k=j; + } + } + swap(a,i,k); + } + k=1; + j=0; + for(i=0;i<4;i++) + { + if(a[i][1]==a[i+1][1]) + { + k++; + } + else + { + sort2(a,k,j); + j=j+k; + k=1; + } + } +} + +void sort2(float a[][6],int n,int m) +{ + void swap(float a[][6],int x,int y); + int i,j,k; + int max; + for(i=m;i