题目描述
参考了大佬的思路,简化了一下
C++ 代码
#include <iostream>
#include <string>
using namespace std;
int main() {
string a, b;
cin >> a >> b;
if (a.size() < b.size()) {
swap(a, b);
}
int f = 0;
for (int i = 0; i < a.size(); ++i) {
if (a[i] == b[0]) {
int k = 0;
for (; k < b.size(); ++k) {
if (a[(i + k) % a.size()]!= b[k]) {
break;
}
}
if (k == b.size()) {
f = 1;
break;
}
}
}
if (f)
cout << "true" << endl;
else
cout << "false" << endl;
return 0;
}