UVa 10115 Automatic Editing

UVa 10115 Automatic Editing
STL还是需要去熟悉啊~现在不是OI了!但是那么多的函数怎么记呐!苦恼。
以下是我的代码:
#include < iostream >
#include
< string >
#include
< cstdio >
using   namespace  std;

int  main()
{
    
/*
    freopen("autoedit.in","r",stdin);
    freopen("autoedit.out","w",stdout);
    //
*/

    
int  n;
    
while (cin >> &&  n)
    {
        getchar();
        
string  origin[ 17 ],replace[ 17 ];
        
for ( int  i = 1 ;i <= n;i ++ )
        {
            getline(cin,origin[i]);
            getline(cin,replace[i]);
        }
        
string  text;
        getline(cin,text);

        
for ( int  i = 1 ;i <= n;i ++ )
        {
            
int  find_result;
            
while ((find_result = text.find(origin[i])) != string ::npos)
            {
                text.erase(text.begin()
+ find_result,text.begin() + find_result + origin[i].size());
                text.insert(find_result,replace[i]);
            }
        }

        cout
<< text << endl;
    }

    
return   0 ;
}

你可能感兴趣的:(UVa 10115 Automatic Editing)