练习 用for 语句将字符串内所有字符用x代替
#include<iostream>
#include<string>
using namespace std;
int main() {
string str;
while (cin >> str)
{
for (auto &c : str) //遍历数组,引用
if (isalpha(c)) //判断是否是字母,是,修改为X;
c = 'X';
cout << str << endl;
}
return 0;
}
【注】:纯小白,希望各位大佬批评指正!