View Code of Problem 79

#include <iostream>
using namespace std;

int main(){
  int n,m,s;
  cin>>n;
  int num[n],res[n];
  for(int j=0;j<n;j++)
    scanf("%d",&num[j]);
  cin>>m;
  s = m%n;
  for(int j=0;j<n;j++){
    if(j+s<n)
      res[j+s] = num[j];
    else
      res[j+s-n] = num[j];
  }
  
  for(int j=0;j<n;j++){
    printf("%d ",res[j]);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 79