HDU 2203 亲和串 (想法题,字符串处理)

来源:互联网 发布:接了网络视频电话 编辑:程序博客网 时间:2024/05/16 12:20

给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。S1+S1后进行查找即可

#include<iostream>#include<sstream>#include<vector>#include<string>#include<algorithm>using namespace std;int main(){    string s1,s2;    while(cin>>s1)    {        cin>>s2;        s1=s1+s1;        int ans=s1.find(s2);        if(ans!=-1) cout<<"yes"<<endl;        else cout<<"no"<<endl;    }    return 0;}


0 0
原创粉丝点击