-->
当前位置:首页 > 题库

PROGRAMMING:Array circulates left

Luz5年前 (2021-05-10)题库398
This problem requires the realization of a simple function to move the array circularly to the left: there are $$n $$($> 0 $$) integers in an array $$a $, on the premise that no other array is allowed, move each integer circularly to the left by $$M $$($$Ge 0 $$) positions, that is, the data in $$a $$is transferred by ($$a $)_ 0 a_ 1 \cdots a_{ N-1} $$) to ($$a)_{ m} \cdots a_{ n-1} a_ 0 a_ 1 \cdots a_{ M-1} $$) (the first number of $$M $$moves to the last position of $$M $$). If you also need to consider the program to move data as few times as possible, how to design the method of moving?
###Input format:
Enter the first line to give the positive integer $$n $$($$Le 100 $$) and the integer $$M $$($$Ge 0 $$); Line 2 gives $$n $$integers separated by spaces.
###Output format:
In one line, output the sequence of integers after the left shift of $$M $$, separated by spaces, and there should be no extra spaces at the end of the sequence.
###Input example:
```in
8 3
1 2 3 4 5 6 7 8
```
###Output example:
```out
4 5 6 7 8 1 2 3
```






answer:If there is no answer, please comment