# include
void shiftleft (int * pinout, int N) {int I; int TMP; TMP = * pinout; for (I = 0; I
0; -- I) {* pinout = * (pinout-1 ); -- pinout;} * pinout = TMP;} void shiftn (int * pinout, int N, int shiftn) {int I; If (shiftn> 0) {for (I = 0; I
Array movement operation, write a function void shitfn (int * pinout, int N, int shiftn), move the shiftn bit pointed to by pinout. If shiftn is a positive number, move it to the left, if it is a negative number, it shifts right. n is the length of the array. For example, array [] = {1, 2, 3, 4}, shiftn = 1, the result after moving is, array [] = {2, 3, 4, 1}
If array [] = {1, 2, 3}, shiftn =-1, the result after moving is: array [] = {3, 1, 2}
The time complexity is O (shiftn * n). Think about it in another way:
Shift shiftn to the left of the loop. The effect is equivalent to: reverse placement of the first shiftn elements, reverse placement of the last n-shiftn elements, and overall inversion of the last n elements. The time complexity is O (n ).