题意:中文题目,自行理解。
解题思路:利用C++中的string类型定义两个字符串,然后将母串自身相加依次,即母串变为一个环,然后利用string中的find函数进行查找即可得出结果。详见代码:
Code:
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
int pos;
string str1,str2;
while(cin>>str1>>str2)
{
if(str1.length() < str2.length()) cout<<"no"<<endl;
else
{
str1 +=str1; pos = -1;
pos = str1.find(str2);
if(pos == -1) cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
}
return 0;
}