diff --git a/AsSortbyNum.svg b/AsSortbyNum.svg new file mode 100644 index 0000000..3e14329 --- /dev/null +++ b/AsSortbyNum.svg @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + AsSortbyNum + + + + + + End + + + + + + + + + + + + + + + + + Integer i + + + + + + + + Integer j + + + + + + + + Integer k + + + + + + + + Integer t + + + + + + + + + + + + + + + + k = i + + + + + + + + + + + + + + + + + + if (stu[j].num < stu[k].num) + + + + + + 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 + + + + + diff --git a/README.md b/README.md index 41341ba..5bf68ba 100644 --- a/README.md +++ b/README.md @@ -435,6 +435,12 @@ Step 4:将结果按照舒徐,总分和平均分的顺序进行输出 #### AsSortbyNum +step 1:利用循环将i赋值给k +step 2:用循环从i+1到n-1比较,将较小的学号赋给k +step 3:如果k与i不相等,每一课的成绩交换 +step 4:总分,平均分,学号,姓名依次交换 + +![按选择法将数组 num 的元素从低到高排序](AsScortNum.svg) #### SortbyName #### SearchbyNum