kilolilo

Untitled

Nov 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  int n=10,s,a[n]={1,2,3,4,5,6,7,8,9,10};
  8.  cin>>s;
  9.  if(s>n){
  10.      s=s%n;
  11.    }
  12.  int step[s],last[n-s];
  13.  for(int i=0;i<s;i++){
  14.      step[i]=a[n-s+i];
  15.    }
  16.  cout<<endl;
  17.  for(int j=0;j<n-s;j++){
  18.      last[j]=a[j];
  19.    }
  20.  for(int i=0;i<s;i++){
  21.      a[i]=step[i];
  22.    }
  23.  for(int j=0;j<n-s;j++){
  24.      a[s+j]=last[j];
  25.    }
  26.  cout<<endl;
  27.  for(int i=0;i<n;i++){
  28.      cout<<a[i]<<"  ";
  29.    }
  30. }
Add Comment
Please, Sign In to add comment