//2.判断一个字符串是否为另外一个字符串旋转之后的字符串。
//例如:给定s1 = AABCD和s2 = BCDAA,返回1,给定s1 = abcd和s2 = ACBD,返回0.
//
//AABCD左旋一个字符得到ABCDA
//AABCD左旋两个字符得到BCDAA
//
//AABCD右旋一个字符得到DAABC
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int find(char * a, char * b)
{
char * tmp = (char *)calloc(strlen(a) * 2 + 1, sizeof(char));
if (tmp == NULL)
{
return 0;
}
strcpy(tmp, a);
strcat(tmp, a);
if (strstr(tmp, b))
{
free(tmp);
return 1;
}
free(tmp);
return 0;
}
int main()
{
char a[] = "AABCD";
char b[] = "BCDAA";
if (find(a, b))
{
printf("zhaodaole\n");
}
else
{
printf("meizhaodao\n");
}
return 0;
}