- 691 名前:デフォルトの名無しさん mailto:sage [2008/02/25(月) 14:12:57 ]
- >>686
これでいいのか? #include <string> #include <iostream> using namespace std; void replace(string& str, string p, string q) { int i = str.find(p); while (i >= 0) { str.replace(i, p.length(), q); i = str.find(p, i + q.length()); } } int main() { string str = "abcdabcd"; replace(str, "bc", "BC"); cout << str << endl; }
|

|