数组元素循环右移问题 (20)

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 
 5 const int maxn = 105;
 6 int a[maxn];
 7 
 8 int main(){
 9 
10     int n, m;
11     cin >> n >> m;
12     for (int i = 0; i < n; i++){
13         cin >> a[(i + m) % n];
14     }
15     for (int i = 0; i < n; i++){
16         if (i == 0)
17             cout << a[i];
18         else
19             cout << " " << a[i];
20     }
21     cout << endl;
22     return 0;
23 }

 

posted @ 2018-03-08 16:07  ouyang_wsgwz  阅读(114)  评论(0编辑  收藏  举报