void reverse(char* str, int begin, int end)
{
char temp;
for( ; begin < end; begin++)
{
temp = str[end];
str[end] = str[begin];
str[begin] = temp;
}
} void left_shift(char *str, int n, int k)
{
k=k% N;
reverse(str, , k -);
reverse(str, k , n - );
reverse(str, , n - );
}
先把前n个字符串反转,再把后面的反转。最后再把整个字符串反转