输入一个字符串以回车符为结束,找出其中的所有的u字母(包括大小写),并将其换成字符串“###”,生成一个新的字符串,输出新生成的字符串(输入的字符串保持不变,如输入的字符串中没有u字母,则新字符串与输入的字符串相同)。
#include <iostream>
#include <string>
int main()
{
std::string string;
std::getline(std::cin, string);
std::string new_string;
const char *p = string.c_str();
while (*p)
{
if (*p == 'u' || *p == 'U')
new_string += "###";
else
new_string += *p;
p++;
}
std::cout << new_string << std::endl;
return 0;
}