POJ 3981.字符串替换
生活随笔
收集整理的這篇文章主要介紹了
POJ 3981.字符串替换
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
POJ 3981.字符串替換
Ideas
字符串替換的水題。
需要注意的就是題目測試用例是多行數(shù)據(jù),一開始沒有注意導(dǎo)致WA,又看了一遍題目才發(fā)現(xiàn)。
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
總結(jié)
以上是生活随笔為你收集整理的POJ 3981.字符串替换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode Algorithm 3
- 下一篇: 使用 Carla 和 Python 的自