PEACE

和平

管理

main.cpp

 1 #include <iostream>
 2 #include <string>
 3 
 4 using namespace std;
 5 
 6 string & replace_all ( string & str, const string & old_value, const string & new_value ) {
 7     while ( true ) {
 8         string::size_type pos ( 0 );
 9         if ( ( pos = str.find ( old_value ) ) != string::npos )
10             str.replace ( pos, old_value.length(), new_value );
11         else
12             break;
13     }
14     return str;
15 }
16 
17 int main ( int argc, char* argv[] ) {
18     string    s1    = argv[1];
19     string    s2    = argv[2];
20     string    s3    = argv[3];
21     cout << replace_all ( s3, s1, s2 ) << endl;
22     return 0;
23 }

附件1

posted on 2019-05-27 22:43  614616185  阅读(176)  评论(0编辑  收藏  举报