Home > Back-end >  For help
For help

Time:11-16

# include "stdio.h"
Int main ()
{
Int N, M, b=0, x=0;
The scanf (" % d % d ", & amp; N, & amp; M);
Int a [1] [N - 1);//N as the count of the number of input, M digits for moves to the right!
While (b<=N - 1)
{
The scanf (" % d ", & amp; A [0] [b]);
B++;
}
B=0;
While (b<=N - 1)
{
If (b + M> N - 1)
A [1] [b] + M - N - 1=a [0] [b];
Else a [1], [b + M]=[0] a [b];
B++;
}
B=0;
While (b<=N - 1)
{
Printf (" % d ", a [1] [b]);
B++;
}
}


If inscribe: an array A of N (& gt; 0) integers, on the premise of not allowed to use the other array, each integer cycle shift to the right M (0) or higher position, the data in A by (A
? 0
?? A
? 1
?? ? A
? N? 1
?? For (A) transform
? N? M
?? ? A
? N? 1
?? A
? 0
?? A
? 1
?? ? A
? N? M? 1
?? ) (last M number cycle moved to the front of M a position), if you need to consider the number of mobile data program as far as possible, how to design method of mobile?

Input format:
Each input contains a test case, input line 1 N (1 N 100 or less or less) and M (0) or higher; Line 2 input N integers, separated by a space between,

The output format:
Output loop in a line moves to the right M after a sequence of integers, separated by a space between the end sequence cannot have extra Spaces,

Input the sample:
6 2
1 2 3 4 5 6
The output sample:
6 1 2 3 4 5
  • Related