Files
PAT/html/b1008.html
T

15 lines
1.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h1>1008. 数组元素循环右移问题 (20)</h1>
<div id="problemContent">
<p>一个数组A中存有N(N&amp;gt0;)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M&gt;=0)个位置,即将A中的数据由(A<sub>0</sub> A<sub>1</sub>……A<sub>N-1</sub>)变换为(A<sub>N-M</sub> …… A<sub>N-1</sub> A<sub>0</sub> A<sub>1</sub>……A<sub>N-M-1</sub>)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?</p>
<p><b>输入格式:</b>每个输入包含一个测试用例,第1行输入N ( 1&lt;=N&lt;=100)、M(M&gt;=0);第2行输入N个整数,之间用空格分隔。</p>
<p><b>输出格式:</b>在一行中输出循环右移M位以后的整数序列,之间用空格分隔,序列结尾不能有多余空格。</p>
<b>输入样例:</b><pre>
6 2
1 2 3 4 5 6
</pre>
<b>输出样例:</b><pre>
5 6 1 2 3 4
</pre>
</div>