程序代码:
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
void foo( string& s, const string& r )
{
for( auto itor=s.begin()
; itor = search( itor, s.end(), r.begin(), r.end(), [](char a, char b){ return ::toupper(a)==::toupper(b); } )
, itor!=s.end()
; advance(itor,r.size()) )
{
if( (itor==s.begin() || ::isspace(*prev(itor))) && (next(itor,r.size())==s.end() || ::isspace(*next(itor,r.size()))) )
{
fill( itor, next(itor,r.size()), '*' );
}
}
}
int main( void )
{
string line, word;
getline( cin, line ) >> word;
//string line = "Our house is at your disposal";
//string word = "our";
foo( line, word );
cout << line << endl;
}