0
点赞
收藏
分享

微信扫一扫

POJ 3981.字符串替换

古得曼_63b6 2022-03-21 阅读 157


​​POJ 3981.字符串替换​​

Ideas

字符串替换的水题。

需要注意的就是题目测试用例是多行数据,一开始没有注意导致WA,又看了一遍题目才发现。

Code

C++

#include <string>
#include <iostream>

using namespace std;

int main() {
string str;
while (getline(cin, str)) {
while (str.find("you") != string::npos)
str.replace(str.find("you"), 3, "we");
cout << str << endl;
}
return 0;
}

在线评测:​​https://vjudge.net/problem/POJ-3981​​



举报

相关推荐

0 条评论