Hello there ,
can anyone write me a function that do shift right once of an array .
it should be circular.
the function gets pointer for an array and returns nothing .
I tried to google it but I didn't find any relevant code.
Printable View
Hello there ,
can anyone write me a function that do shift right once of an array .
it should be circular.
the function gets pointer for an array and returns nothing .
I tried to google it but I didn't find any relevant code.
I found the solution :P ..
left shift
temp=a[0];
for(i=0;i<n-a;i++)
a[i]=a[i+1];
a[n-1]=temp;
shift right
temp=a[n-1];
for(i=n-1;i>0;i--)
a[i]=a[i-1];
a[0]=temp;
On the other note, we are here not to write code for you. We are here to help to write your own code.
ssharish
I know but when u are out of options you will try anything just to get a solution.
It doesn't really seem like you were out of options. Because it doesn't seem like you used the option called "think about the problem".
Quzah.