Output data exchange problem solution

Input n (n <100) number, find the smallest number wherein the exchanging data with it the foremost outputs these numbers. 

Input plurality of input data sets, each representing one line in each line is an integer n, the number values ​​in this test case, is followed by n integers.

n = 0 indicates the end of input, not treated. Output For each case, the number of columns after the switching output, each output per line. Sample Input

4 2 1 3 4
5 5 4 3 2 1
0

Sample Output

1 2 3 4
1 4 3 2 5

 

Guess you like

Origin www.cnblogs.com/hrlsm/p/12308466.html