循环移位 题解:
#include <iostream>
#include <cstring>
using namespace std;
int main(){
string a, b;
while(cin >> a >> b){
// 在b的末尾拼接b的长度为(a的长度-1)的开头就能检验循环的情况(相当于把一个环给展开了)
b += b.substr(0, a.length()-1);
if(b.find(a)!=-1){
cout << "yes" << endl;
}else{
cout << "no" << endl;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发