给定两个字符串s1和s2,要求判定s2是否能够通过s1循环移位得到的字符串包含。例如,给定s1=AABCD和s2=CDAA,返回true;给定s1=ABCD和s2=ACBD,返回false。 /* ============================================================================ Name : Strstr.c Author : QiBaoyuan Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { char src[] = "AABBCD";//sizeof(src)=7,strlen(src)=6 char des[] = "CDAA"; int len = strlen(src); char *con = (char*) malloc(len * 2 + 1); strcpy(con, src); strcat(con, src); if (strstr(con, des) != NULL) printf("ok"); else printf("not exists"); return EXIT_SUCCESS; }