A30579 字符串移位 全站首个题解
2025-07-12 22:27:33
发布于:湖北
8阅读
0回复
0点赞
#include <iostream>
#include <string>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
std::string s1, s2;
std::cin >> s1 >> s2;
bool found = false;
if (s1.length() >= s2.length()) {
std::string s1_doubled = s1 + s1;
if (s1_doubled.find(s2) != std::string::npos) {
found = true;
}
}
if (!found && s2.length() >= s1.length()) {
std::string s2_doubled = s2 + s2;
if (s2_doubled.find(s1) != std::string::npos) {
found = true;
}
}
if (found) {
std::cout << "true\n";
} else {
std::cout << "false\n";
}
return 0;
}
这里空空如也
有帮助,赞一个