Problem B
Mjehuric
Goran has five wooden pieces arranged in a sequence. There
is a number between
-
If the number on the first piece is greater than the number on the second piece, swap them.
-
If the number on the second piece is greater than the number on the third piece, swap them.
-
If the number on the third piece is greater than the number on the fourth piece, swap them.
-
If the number on the fourth piece is greater than the number on the fifth piece, swap them.
-
If the pieces don’t form the sequence
, go to step 1.
Write a program that, given the initial ordering of the pieces, outputs the ordering after each swap.
Input
The first line contains five integers separated by single
spaces, the ordering of the pieces. The numbers will be between
Output
After any two pieces are swapped, output the ordering of the pieces, on a single line separated by spaces.
Sample Input 1 | Sample Output 1 |
---|---|
2 1 5 3 4 |
1 2 5 3 4 1 2 3 5 4 1 2 3 4 5 |
Sample Input 2 | Sample Output 2 |
---|---|
2 3 4 5 1 |
2 3 4 1 5 2 3 1 4 5 2 1 3 4 5 1 2 3 4 5 |