#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool isRotation(string &str1 , string &str2)
{
string temp;
temp=str2+str2;
if(temp.find(str1)!=temp.npos)
return true;
else
return false;
}
int main()
{
int m,n;
cin>>m>>n;
string str1;
string str2;
cin>>str1;
cin>>str2;
bool res;
res=isRotation(str1,str2);
if(res==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
1/string 定义的变量可以直接相加以达到拼接的目的
2/algorithm 中find函数的使用
3/如果查找的结果是string.npos,其代表着没有找到。