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

PROGRAMMING:The process of sorting by choice

Luz5年前 (2021-05-10)题库421
This problem requires the use of selection sorting, the given $$n $$integers from small to large sorting output, and output sorting process in each step of the intermediate results.
The algorithm steps are as follows:
Step $$0: find the minimum number in the unordered number of $$n $$($$a [0] $~ $$a [n-1] $), and exchange it with $$a [0] $;
Step $$1: find the minimum number in the remaining unordered number of $$n-1 $$($$a [1] $~ $$a [n-1] $), and exchange it with $$a [1] $;
……
Step $$k $: find the minimum number in the remaining unordered number of $$n-k $$($$a [k] ~ a [n-1] $), and exchange it with $$a [k] $;
……
Step $$n-2 $: find the minimum number in the remaining unordered number of $$2 $($$a [n-2] $~ $$a [n-1] $), and exchange it with $$a [n-2] $.
###Input format:
Enter the first line to give a positive integer of no more than 10 $$n $. The second line gives $$n $$integers separated by spaces.
###Output format:
In each row, output the intermediate result of the corresponding step in the sorting process, that is, the value of $$a [0] $~ $$a [n-1] $$after each step. There is a space between adjacent numbers, and there must be no extra space at the end of the row.
###Input example:
```in
four
5 1 7 6
```
###Output example:
```out
1 5 7 6
1 5 7 6
1 5 6 7
```






answer:If there is no answer, please comment