PAT (Basic Level) Practice (中文)1008 数组元素循环右移问题 (20 分)

题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805316250615808

 #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
int n,m;
int a[];
int b[];
int main()
{
while(cin>>n>>m){
for(int i=;i<n;i++) cin>>a[i];
m%=n;
for(int i=;i<m;i++){
b[i]=a[n-m+i];
//cout<<b[i]<<" ";
}
for(int i=m;i<n;i++){
b[i]=a[i-m];
//cout<<b[i]<<" ";
}
for(int i=;i<n;i++){
if(i==) cout<<b[i];
else cout<<" "<<b[i];
}
cout<<endl;
}
return ;
}
上一篇:Windows NT驱动程序的基本结构和实例


下一篇:normalization归一化