Quote:
Input- 1 2 3 4 5 6
Output-2 1 4 3 6 5
The sorting should be similar like in the given following sequence. The numbers can be random.
Your example is bad because the numbers are consecutive and already sorted, All it show is a swap of pairs on output.
Quote:
I tried to change the position of i. If i is even. I increase it by one. If I is odd. I decrease it by one.
Do not try to change values because it will fail on 2, 3, 4, 5, 6, 7 and on 2, 4, 6, 8.
Just do a normal sort, then swap pairs.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.