Reverse an Array With Two Walking Pointers
mediumQuestion 467Reverse an array in place using TWO POINTERS instead of indexes. Do not build a second array.
Read an integer n (at most 64), then n integers into a local array, reverse it, then print all n values on one line, separated by single spaces, with no trailing space.
For the input:
5 1 2 3 4 5
the output is exactly what is shown in Expected Output.
The line ends with a newline.
Expected output
5 4 3 2 1= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.