View Code of Problem 79

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[100],d[100];
	while(cin>>n){
		int m;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		cin>>m;
		reverse(a,a+n-m);
		reverse(a+n-m,a+n);
		reverse(a,a+n);
		for(int i=0;i<n;i++){
			if(i==n-1){
				cout<<a[i];
			}
			else{
				cout<<a[i]<<' ';
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 79