A natural number N is read, followed by N integer values. Build a singly linked list containing the values in reading order (the first value is the head, the last is the tail).
Reverse the list by modifying the links (without copying values into an auxiliary array). After reversing, traverse the list and print the values separated by single spaces.
Use a structure Node { int val; Node* next; } with new for allocation. Do not use STL containers.