请升级 HydroOJ 到 4.19.0 以上版本以正常使用此插件功能。
1 条题解
-
0
#include #include using namespace std;
int main() { string s, find, replace; getline(cin, s); getline(cin, find); getline(cin, replace);
string result; int n = s.length(); int m = find.length(); int i = 0; while (i < n) { bool match = true; if (i + m <= n) { for (int j = 0; j < m; j++) { if (s[i + j] != find[j]) { match = false; break; } } } else { match = false; } if (match) { result += replace; i += m; } else { result += s[i]; i++; } } cout << result << endl; return 0;}
信息
- ID
- 642
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 10
- 标签
- 递交数
- 10
- 已通过
- 3
- 上传者