题目:https://pintia.cn/problem-sets/17/problems/262

题解:https://www.liuchuo.net/archives/522

代码:

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;	
	vector<int> a(n);
	for(int i=0; i<n;i++){
		cin>>a[i];
	}
	m= m%n;
	reverse(begin(a), begin(a)+n);
	reverse(begin(a), begin(a)+m);
	reverse(begin(a)+m, end(a));
	
	for(int i=0; i<n-1;i++){
		cout<<a[i]<<" ";
	}
	cout<<a[n-1];
	
	return 0;
}

 

 posted on 2020-07-23 15:29  邢涌芝  阅读(109)  评论(0编辑  收藏  举报