Module: STL algorithms


Problem

1/6

Cyclic shift with rotate

Problem

Cycle through the elements of the array by the desired number of elements.
 
Use as few assignments as possible.
 
Input
Enter a list of numbers. All numbers in the list are on the same line.
 
Output
First given number N — the number of elements in the array and the number of positions to shift K (1<=N<=100, -1000<=K<=1000). Further, through the space, N numbers are written — array elements. The array consists of integers.

Enter Output
5 2
12  3 4 5
3 4 5 1 2
5 1000
1 2 3 4 5
1 2 3 4 5
5-2
1 2 3 4 5
4 5 1 2 3