Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n=10,s,a[n]={1,2,3,4,5,6,7,8,9,10};
- cin>>s;
- if(s>n){
- s=s%n;
- }
- int step[s],last[n-s];
- for(int i=0;i<s;i++){
- step[i]=a[n-s+i];
- }
- cout<<endl;
- for(int j=0;j<n-s;j++){
- last[j]=a[j];
- }
- for(int i=0;i<s;i++){
- a[i]=step[i];
- }
- for(int j=0;j<n-s;j++){
- a[s+j]=last[j];
- }
- cout<<endl;
- for(int i=0;i<n;i++){
- cout<<a[i]<<" ";
- }
- }
Add Comment
Please, Sign In to add comment