亲和串。。。错误案例

#include<stdio.h>
#include<string.h>
#define n 1000005
int main()
{
 char a[1000005]={0},b[1000005]={0},c[1000005]={0};
 int i,count,x,y;
 
 while(gets(a))
 {
  count=0;
  gets(b);
  x=strlen(a);
  y=strlen(b);
  if(y>x)
  {
   printf("no ");
   count=1;
  }
  else
  {
   strcpy(c,a);
   strcat(c,a);
   if(strstr(c,b))
   {
    printf("yes ");
    count=1;
   }
  }
  if(count!=1)
  {
   printf("no");
  }
 }
 return 0;
}

人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现,现在长大了却不知道怎么去判断亲和串了,于是他只好又再一次来请教聪明且乐于助人的你来解决这个问题。
亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。

Input

Output

如果s2是s1的亲和串,则输出"yes",反之,输出"no"。每组测试的输出占一行。

Sample Input

AABCD
CDAA
ASD
ASDF

Sample Output

yes
no
原文地址:https://www.cnblogs.com/luzhongshan/p/3868517.html