Did you know that you can also reverse arrays and group them according to your liking with proper code?
Let's try it to believe it.
Instructions:
- Input a random positive integer. Then, create an integer array with a size the same as the inputted integer.
- Then, using loops, add random integer values into the array one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
- Print out the list's new order in this manner, with each number separated by a space per row:
- second-half values
- middle value
- first-half values
- Refer to the sample output for a clearer view on how it is to be printed out.
Input
The first line contains an odd positive integer. It is guaranteed that this integer is greater than or equal to 3.
The next lines contains an integer.
5
1
3
4
5
2
Output
A line containing grouped arrays.
{2,5}-{4}-{3,1}
Comments
Leave a comment