diff --git a/Arrays/rotateArray.cpp b/Arrays/rotateArray.cpp new file mode 100644 index 0000000..f349615 --- /dev/null +++ b/Arrays/rotateArray.cpp @@ -0,0 +1,59 @@ +#include +using namespace std; + + + // } Driver Code Ends +class Solution{ + public: + + //Function to rotate an array by d elements in counter-clockwise direction. + void rotateArr(int arr[], int d, int n){ + int temp[n]; + int j=0; + for(int i=d;i> t; + + while(t--){ + int n, d; + + //input n and d + cin >> n >> d; + + int arr[n]; + + //inserting elements in the array + for(int i = 0; i < n; i++){ + cin >> arr[i]; + } + Solution ob; + //calling rotateArr() function + ob.rotateArr(arr, d,n); + + //printing the elements of the array + for(int i =0;i +using namespace std; +int main(){ +char direction[1000]; +cout<<"Enter the direction First letter"<=0 and y>=0){ + while(y--){ + cout<<'N'; + } + while(x--){ + cout<<'E'; + } +} +if(x<=0 and y>=0){ + while(y--){ + cout<<'N'; + } + while(x++){ + cout<<'W'; + } +} +if(x<=0 and y<=0){ + while(y++){ + cout<<'S'; + } + while(x++){ + cout<<'W'; + } +} +if(x>=0 and y<=0){ + while(y++){ + cout<<'S'; + } + while(x--){ + cout<<'E'; + } +} +return 0; +} \ No newline at end of file