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

PROGRAMMING:The k-th round selection method

Luz5年前 (2021-05-10)题库385
As we all know, LN is a Dalao and lty is a five. Now, lty asks LN, can you sort n numbers by selection method to make them orderly from small to large? Ln thinks this problem is very simple, and then asks lty, can you output the result of k-round selection sorting on the basis of this? Lty is a weak chicken, of course not, so I asked you about this problem. Can you solve this problem for lty? Give you n numbers, output these n numbers after K round selection method sorting results.
Sorting by selection method: traverse the whole array. In the first round, traverse the first bit to the nth bit to find the smallest one to exchange with the first bit. In the second round, traverse the second bit to the nth bit to find the smallest one to exchange with the second bit, and so on( Exchange only once per round)
###Input format:
Input n and K (1 ≤ K < n ≤ 100) in line 1, and n positive integers to be sorted in line 2, separated by spaces.
###Output format:
In a row, output the intermediate result sequence after the k-th scan by selection sorting, and separate the numbers with spaces, but there should be no extra spaces at the end.
###Input example:
Here is a set of inputs. For example:
```in
6 2
2 3 5 1 6 4
```
###Output example:
The corresponding output is given here. For example:
```out
1 2 5 3 6 4
```







answer:If there is no answer, please comment