You are viewing a single comment's thread. Return to all comments →
no Rotation but still does the job :v CHECK THIS out c++ lovers
im noob in coding so i wrote it so big :(
int b,n,k,q,ans=0; cin>>n>>k>>q; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; if(k==n){ for(int i=0;i<q;i++) { cin>>b; cout<<a[b]<<endl; } } else if(k>n) { while(k>n) k=k-n; for(int i=0;i<q;i++) { ans=n-k; cin>>b; ans+=b; if(ans>n-1) ans-=n; cout<<a[ans]<<endl; } } else if(k<n) { for(int i=0;i<q;i++) { ans=n-k; cin>>b; ans+=b; if(ans> n-1) ans-=n; cout<<a[ans]<<endl; } } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
no Rotation but still does the job :v CHECK THIS out c++ lovers
im noob in coding so i wrote it so big :(
}