Select sort-Algorithm
1. Split objects to be sorted2Partially, one is sorted, and the other is unordered.
2. Select a minimum value from the unordered part of the backend and put it to the last one in the sorted part of the front end.
E. g:
Before sorting: 70 80 31 37 10 1 48 60 33 80
[1] 80 31 37 10 7048 60 33 80 select minimum value 1
[1 10] 31 37 80 7048 60 33 80 selected minimum 10
[1 10 31] 37 80 7048 60 33 80 selected minimum value 31
[1 10 31 33] 80 7048 60 37 80 ......
[1 10 31 33 37] 7048 60 80 80 ......
[1 10 31 33 37 48] 70 60 80 80 ......
[1 10 31 33 37 4860] 70 80 80 ......
[1 10 31 33 37 4860 70] 80 80 ......
[1 10 31 33 37 4860 70 80] 80 ......
# Define swaper (x, y) {int t; t = x; X = y; y = T;} select sort-program segment: int selectionsort (int A [], int lens) {int I, j, k; for (I = 0; I <lens; I ++) {int minindex = I; for (j = I + 1; j <lens; j ++) {if (a [minindex]> A [J]) {minindex = J ;}} if (I! = Minindex) swaper (A [I], a [minindex]);} return 0;} int selectionsort2 (int A [], int lens) {int I, J, K; for (I = 0; I <lens; I ++) {for (j = I + 1; j <lens; j ++) {if (a [I] <A [J]) {swaper (A [I], a [J]) ;}} return 0 ;}