• String Replace 1.0


    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

  • 相关阅读:
    R
    P
    O
    M
    二分算法的一些思考
    I
    H
    G
    5-46 新浪微博热门话题 (30分)——unfinished HASH
    BZOJ 1179: [Apio2009]Atm
  • 原文地址:https://www.cnblogs.com/rms365/p/10934006.html
Copyright © 2020-2023  润新知