文章

1

粉丝

0

获赞

0

访问

60

头像
删除字符串2 题解:
P1027 贵州大学机试题
发布于2026年2月21日 16:11
阅读数 60

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string toLower(string s) {
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    return s;
}
void removeGZU(string &s) {
    string target = "gzu";
    size_t pos;
    while (true) {
        string lowerS = toLower(s); 
        pos = lowerS.find(target); 
        if (pos == string::npos) break; 
        s.erase(pos, target.length()); 
    }
}
int main() {
    string s;
    if (getline(cin, s)) {
        removeGZU(s);
        cout << s << endl;
    }
    return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发