diff --git a/Array_left_rotation.cpp b/ArrayLeftRotation.cpp similarity index 94% rename from Array_left_rotation.cpp rename to ArrayLeftRotation.cpp index 11fa154d1..36278e1bb 100644 --- a/Array_left_rotation.cpp +++ b/ArrayLeftRotation.cpp @@ -1,30 +1,30 @@ -#include -using namespace std; -int main(){ - int n,k; - cout<<"Enter size of array=\t"; - cin>>n; - cout<<"Enter Number of indeces u want to rotate the array to left=\t"; - cin>>k; - int a[n];cout<<"Enter elements of array=\t"; - for(int i=0;i>a[i]; - } - int temp=0; - for(int i=0;i +using namespace std; +int main(){ + int n,k; + cout<<"Enter size of array=\t"; + cin>>n; + cout<<"Enter Number of indeces u want to rotate the array to left=\t"; + cin>>k; + int a[n];cout<<"Enter elements of array=\t"; + for(int i=0;i>a[i]; + } + int temp=0; + for(int i=0;i -using namespace std; -int main(){ - int n,k; - cout<<"Enter size of array=\t"; - cin>>n; - cout<<"Enter Number of indices u want to rotate the array to right=\t"; -cin>>k; -int a[n]; -cout<<"Enter elements of array=\t"; - for(int i=0;i>a[i]; - int temp=0; - for(int i=0;i=0;j--){ - if(j==0){ - a[j]=temp; - } - else{ - a[j]=a[j-1];} - - } - - } - cout<<"Your rotated array is=\t"; - for(int i=0;i +using namespace std; +int main(){ + int n,k; + cout<<"Enter size of array=\t"; + cin>>n; + cout<<"Enter Number of indices u want to rotate the array to right=\t"; +cin>>k; +int a[n]; +cout<<"Enter elements of array=\t"; + for(int i=0;i>a[i]; + int temp=0; + for(int i=0;i=0;j--){ + if(j==0){ + a[j]=temp; + } + else{ + a[j]=a[j-1];} + + } + + } + cout<<"Your rotated array is=\t"; + for(int i=0;i