diff --git a/README.md b/README.md index 41341ba..1c8c28b 100644 --- a/README.md +++ b/README.md @@ -430,6 +430,12 @@ Step 4:将结果按照舒徐,总分和平均分的顺序进行输出 #### AverSumofEveryCourse #### SortbyScore +step 1:利用循环将i赋值给k +step 2:用循环从i+1到n-1比较,将较小的赋给k +step 3:如果k与i不相等,每一课的成绩交换 +step 4:总分,平均分,学号,姓名依次交换 + +![按选择法将数组 sum 的元素值排序](SortbyScore.svg) #### SortbyScore diff --git a/SortbyScore.svg b/SortbyScore.svg new file mode 100644 index 0000000..3eeb1d7 --- /dev/null +++ b/SortbyScore.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + SortbyScore + + + + + + Return Integer + + + + + + + + + + + + + + + + + Integer i + + + + + + + + Integer j + + + + + + + + Integer k + + + + + + + + Integer t + + + + + + + + + + + + + + + + k = i + + + + + + + + + + + + + + + + + + if ((*compare)(stu[j].sum, stu + [k].sum)) + + + + + + k = j + + + + + + + True + + + False + + + + + + j = i+1 to n-1 + + + + Next + + + Done + + + + + + + + + + + + + k!=i + + + + + + + + + + + + + + + + + + + + + + SwapFloat(&stu[k].score[t], & + stu[i].score[t]) + + + + + + t = 0 to m-1 + + + + Next + + + Done + + + + + + + + SwapFloat(&stu[k].sum, &stu[i]. + sum) + + + + + + + + SwapFloat(&stu[k].aver, &stu[i]. + aver) + + + + + + + + SwapLong(&stu[k].num, &stu[i]. + num) + + + + + + + + SwapChar(stu[k].name, stu + [i].name) + + + + + + + + True + + + False + + + + + + + i = 0 to n-2 + + + + Next + + + Done + + + + +