#include<stdio.h>
#include<string.h>
void reverse(char *left, char *right)
{
while (right > left)
{
char tmp = *right;
*right = *left;
*left = tmp;
right--;
left++;
}
}
void left(char src[], int len)
{
int n = 0;
scanf("%d", &n);
reverse(src, src + n-1);
reverse(src + n, src + len-1);
reverse(src, src + len-1);
}
int main()
{
char src[] = "123456";
int len = strlen(src);
left(src, len);
printf("%s\n",src);
system("pause");
return 0;
}
采用了三次翻转法。