You are playing a little game with your friends. This game is to remember the order of balls in the cups. First, there will be a lot of balls with numbers shown to your friends. All the balls are then covered with a cup. You need to reverse some cups several times and let your friends indicate what the new order is.
In this quiz, you need to implement linked list in this game, and print out the final order after reversing the assigned segment.
Reminder:
Remember to have #include "function.h" in your code.
You only need to finish the function void reverse(int left, int right) ;
Here is a brief example:
The first line contains two integers N and T , representing the number of cups and how many times you reverse the cups.
The second line contains N integers, B1, B2, B3, BN, representing the ball numbers in the cups one by one.
The remaining T lines contains two integer L, R, representing the first cup and last cup of segment you need to reverse.
It is guaranteed that:
One line contains N numbers, representing the final order of balls after reversing assigned segment.