POJ 3981.字符串替换
Ideas
字符串替换的水题。
需要注意的就是题目测试用例是多行数据,一开始没有注意导致WA,又看了一遍题目才发现。
Code
C++
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;
}