AcWing 3641. 删除字符串2
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, x, y, p;
int f[N];
bool flag;
const string zc = "gzu";
void solve() {
string str,str2;
cin >> str;
str2 = str;
for (char&ch : str) {
if (ch >= 'A' && ch <= 'Z') {
ch += 32;
}
}
while ((p = str.find(zc)) != -1) {
str2.replace(p, zc.size(), "\n");
str.replace(p, zc.size(), "\n");
}
while ((p = str2.find("\n")) != -1) {
str2.replace(p, 1, "");
}
cout << str2;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}