diff --git a/file b/file index f68282d..606d63e 100644 --- a/file +++ b/file @@ -157,4 +157,217 @@ void AverSumofEveryCourse(STU stu[], int n, int m) j+1, sum[j], aver[j]); } /* ----------- end ----------- */ -} \ No newline at end of file +} +// 函数功能:按选择法将数组sum的元素值排序 +void SortbyScore(STU stu[],int n,int m,int (*compare)(float a,float b)) +{ + int i, j, k, t; + for (i=0; i b; // 这样比较决定了按降序排序,如果a>b,则交换 +} +// 交换两个单精度浮点型数据 +void SwapFloat(float *x, float *y) +{ +float temp; +temp = *x; +*x = *y; +*y = temp; +} +// 交换两个长整型数据 +void SwapLong(long *x, long *y) +{ + long temp; +temp = *x; +*x = *y; +*y = temp; +} +// 交换两个字符串 +void SwapChar(char x[], char y[]) +{ +char temp[MAX_LEN]; +strcpy(temp, x); +strcpy(x, y); +strcpy(y, temp); +} +// 函数功能:按选择法将数组num的元素值按从低到高排序 +void AsSortbyNum(STU stu[], int n, int m) +{ + int i, j, k, t; + for (i=0; i=0 && stu[i].score[j]<60)t[0]++; + else if (stu[i].score[j]<70) t[1]++; + else if (stu[i].score[j]<80) t[2]++; + else if (stu[i].score[j]<90) t[3]++; + else if (stu[i].score[j]<100) t[4]++; + else if (stu[i].score[j] == 100) t[5]++; + } + for (i=0; i<=5; i++) + { + if (i==0) printf("<60\t%d\t%.2f%%\n",t[i],(float)t[i]/n*100); + else if (i==5) printf("%d\t%d\t%.2f%%\n", +(i+5)*10,t[i],(float)t[i]/n*100); + else printf("%d-%d\t%d\t%.2f%%\n", +(i+5)*10, (i+5)*10+9, t[i], (float)t[i]/n*100); + } + } +} +// 函数功能: 打印学生成绩 +void PrintScore(STU stu[], int n, int m) +{ + int i, j; + for (i=0; i