题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805316250615808
题解:
1 #include<iostream> 2 using namespace std; 3 4 int main(){ 5 int n, m; 6 cin >> n >> m; 7 8 int *a = new int[n]; 9 for (int i = 0; i < n; i++) 10 cin >> a[i]; 11 int f = m%n;//当大于数组的长度时,直接取模减少移动次数 12 13 for (int i = n - f; i < n; i++) 14 cout << a[i] << " "; 15 for (int i = 0; i < n - f; i++){ 16 if (i != n - f - 1) cout << a[i] << " "; 17 else cout << a[i];//输出的最后一个没有空格 18 } 19 return 0; 20 }
来源:https://www.cnblogs.com/Gzu_zb/p/9364739.html