1163: 亲和串(字符串)

来源:互联网 发布:为知笔记导出 苹果 编辑:程序博客网 时间:2024/05/18 22:42

Description

判断亲和串。亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。

Input

本题有多组测试数据,每组数据的第一行包含输入字符串s1,第二行包含输入字符串s2,s1与s2的长度均小于100000。

Output

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

Sample Input

AABCDCDAAASDASDFababa

Sample Output

yesnono

HINT



//string类的查找函数://int find(char c,int pos=0) const;从pos开始查找字符c在当前串的位置#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;}




原创粉丝点击