Question: c++ rotating array to right side is working, but rotating to left side is not working with some numbers how do i fix this with
c++
rotating array to right side is working, but rotating to left side is not working with some numbers
how do i fix this with using below code
#include
using namespace std;
void rotate(int a[], int n, int k)
{
int i, b[n];
int np=-1;
if(k>=0)
{
for(i=0; i { b[(i+n+k)%n]=a[i]; } } else { for(i=0; i { b[(i+n+k)%n]=a[i]; } } for(i=0; i { cout< } } int main() { int a[8]={0,1,2,3,4,5,6,7}; rotate(a, 8 ,-64); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
