fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. // element serch in rotated element in n times
  7. int rot;
  8. cout<<"Enter the number of rotation\n";
  9. cin>>rot;
  10. int arr[]={4,5,6,7,8,9,10};
  11. int size=7;
  12. int ans=-1;
  13. for(int i=0;i<rot;i++){
  14. int temp=arr[size-1];
  15. for(int j=size-1;j>0;j--){
  16. arr[j]=arr[j-1];
  17. }
  18. arr[0]=temp;
  19. }
  20.  
  21. for(int i=0; i<size;i++){
  22. cout<<arr[i]<<" ";
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5320KB
stdin
2
stdout
Enter the number of rotation
9  10  4  5  6  7  8