判断亲和串。亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
判断亲和串。亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b;
int position;
while(cin>>a>>b)
{
if(a.size()<b.size())
{
cout<<"no"<<endl;
}
else
{
a=a+a;
position=a.find(b);
if(position==-1)
cout<<"no"<<endl;
else
cout<<"yes"<<endl;
}
}
return 0;
}原文:http://blog.csdn.net/zuguodexiaoguoabc/article/details/44682435