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. }
  19.  
  20. for(int i=0; i<size;i++){
  21. cout<<arr[i]<<" ";
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 5312KB
stdin
2
stdout
Enter the number of rotation
4  4  4  5  6  7  8