-->
当前位置:首页 > 题库

PROGRAMMING:Simple selection sort displays the k-th row

Luz5年前 (2021-05-10)题库519
Sorting n integers from small to large works like this: select the largest (small) of all numbers and exchange with the last (first). Through a scan, the last element must be the largest element (or the first element must be the smallest element). Then the remaining N − 1 elements are scanned a second time by the same method. And so on, finally only need to deal with two elements, that is to complete the sorting of N numbers.
This problem requires any given K (< n) according to the principle of finding large, output the intermediate result sequence after the k-th scan.
###Input format:
Input n and K in the first line (1 ≤ K < n ≤ 100), and N integers to be sorted in the second line, separated by spaces.
###Output format:
In a row, output the intermediate result sequence after the k-th scan of the sorting method. The numbers are separated by spaces, but there must be no extra spaces at the end.
###Input example:
```in
6 2
2 3 5 1 6 4
```
###Output example:
```out
2 3 4 1 5 6
```







answer:If there is no answer, please comment