#include<iostream>
using namespace std;
void reverse(int a[],int low,int high){
while(low<high){
int temp=a[low];
a[low]=a[high];
a[high]=temp;
low++;
high--;
}
}
void rightrotate(int a[],int n,int k){
reverse(a,0,n-1);
reverse(a,0,k-1);
reverse(a,k,n-1);
}
void printarray(int a[],int n){
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
cout<<"\n";
}
int main(){
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
rightrotate(a,n,k);
printarray(a,n);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: