#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
int main ()
{
std::vector<std::string> seq { "one", "zero", "two", "three", "zero", "four", "five" } ;
const auto print = [&seq]
{ for( const auto& s : seq ) std::cout << s << ' ' ; std::cout << '\n' ; } ;
print() ;
// replace "zero" with "nil"
const std::string zero = "zero" ;
const std::string nil = "nil" ;
std::replace( seq.begin(), seq.end(), zero, nil ) ;
print() ;
// replace strings which start with the character t with "ttttt" ;
std::replace_if( seq.begin(), seq.end(),
[]( const std::string& s ) { return !s.empty() && s[0] == 't' ; },
"ttttt" ) ;
print() ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4gKCkKewogICAgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IHNlcSB7ICJvbmUiLCAiemVybyIsICJ0d28iLCAidGhyZWUiLCAiemVybyIsICJmb3VyIiwgImZpdmUiIH0gOwogICAgY29uc3QgYXV0byBwcmludCA9IFsmc2VxXQogICAgeyBmb3IoIGNvbnN0IGF1dG8mIHMgOiBzZXEgKSBzdGQ6OmNvdXQgPDwgcyA8PCAnICcgOyBzdGQ6OmNvdXQgPDwgJ1xuJyA7IH0gOwogICAgcHJpbnQoKSA7CgogICAgLy8gcmVwbGFjZSAiemVybyIgd2l0aCAibmlsIgogICAgY29uc3Qgc3RkOjpzdHJpbmcgemVybyA9ICJ6ZXJvIiA7CiAgICBjb25zdCBzdGQ6OnN0cmluZyBuaWwgPSAibmlsIiA7CiAgICBzdGQ6OnJlcGxhY2UoIHNlcS5iZWdpbigpLCBzZXEuZW5kKCksIHplcm8sIG5pbCApIDsKICAgIHByaW50KCkgOwoKICAgIC8vIHJlcGxhY2Ugc3RyaW5ncyB3aGljaCBzdGFydCB3aXRoIHRoZSBjaGFyYWN0ZXIgdCB3aXRoICJ0dHR0dCIgOwogICAgc3RkOjpyZXBsYWNlX2lmKCBzZXEuYmVnaW4oKSwgc2VxLmVuZCgpLAogICAgICAgICAgICAgICAgICAgICAgIFtdKCBjb25zdCBzdGQ6OnN0cmluZyYgcyApIHsgcmV0dXJuICFzLmVtcHR5KCkgJiYgc1swXSA9PSAndCcgOyB9LAogICAgICAgICAgICAgICAgICAgICAgICJ0dHR0dCIgKSA7CiAgICBwcmludCgpIDsKfQo=