View Code of Problem 79

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t[n];
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	int m;
	cin>>m;
	int b[n];
	for(int j=0;j<n;j++){
		b[j]=t[j];
	}
	for(int j=0;j<n;j++){
		b[(j+m)%n]=t[j];
	}
	for(int i=0;i<n;i++){
		if(i!=n-1){
		cout<<b[i]<<" ";	
		}
		else{
			cout<<b[i];
		}
		
	}
			
	return 0;
}

Double click to view unformatted code.


Back to problem 79