//编写函数实现字符串旋转
#include <stdio.h>
#include <assert.h>
#include <string.h>
void reverse(char *left, char *right)    
{
	char temp;
	assert(left);
	assert(right);
	while (right > left)
	{
		temp = *left;
		*left = *right;
		*right = temp;
		left++;
		right--;
	}
}
char *rotate(char *src, int n)
{
	int len = strlen(src);
	assert(src);
	reverse(src, src + n-1);
	reverse(src + n, src+len-1);
	reverse(src, src + len - 1);
	return src;
}
int main()
{
	char p[] = "abcdef";
	printf("%s\n", rotate(p, 2));
	return 0;
}