#include <string>
#include <cstdarg>
#include <iostream>
std::string string_replace(std::string s, char r, int countc, ...)
{
char p;
va_list ap;
va_start(ap, countc);
for(int j = 0; j < countc; ++j)
{
p = va_arg(ap, char);
for(char &c : s)
{
if(c == p)
{
c = r;
}
}
}
va_end(ap);
return s;
}
int main()
{
std::cout << string_replace("aeiou and sometimes y", 'z', 5, 'a', 'e', 'i', 'o', 'u') << std::endl;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNzdGRhcmc+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnN0ZDo6c3RyaW5nIHN0cmluZ19yZXBsYWNlKHN0ZDo6c3RyaW5nIHMsIGNoYXIgciwgaW50IGNvdW50YywgLi4uKQp7CiAgICBjaGFyIHA7CiAgICB2YV9saXN0IGFwOwogICAgdmFfc3RhcnQoYXAsIGNvdW50Yyk7CiAgICBmb3IoaW50IGogPSAwOyBqIDwgY291bnRjOyArK2opCiAgICB7CiAgICAgICAgcCA9IHZhX2FyZyhhcCwgY2hhcik7CiAgICAgICAgZm9yKGNoYXIgJmMgOiBzKQogICAgICAgIHsKICAgICAgICAgICAgaWYoYyA9PSBwKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjID0gcjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHZhX2VuZChhcCk7CiAgICByZXR1cm4gczsKfQoKaW50IG1haW4oKQp7CiAgICBzdGQ6OmNvdXQgPDwgc3RyaW5nX3JlcGxhY2UoImFlaW91IGFuZCBzb21ldGltZXMgeSIsICd6JywgNSwgJ2EnLCAnZScsICdpJywgJ28nLCAndScpIDw8IHN0ZDo6ZW5kbDsKfQo=