#include <iostream>
#include <string>
using namespace std;
//using namespace string;
int main(){
string s;
cin >> s;
for (auto &c : s){
c = 'x';
}
cout << s << endl;
return 0;
}
C++ primer P82 练习3.6
最新推荐文章于 2025-01-05 17:13:58 发布
本文展示了一个简单的C++程序示例,该程序通过遍历输入的字符串并将每个字符替换为‘x’来演示字符串操作的基本方法。此代码段利用了标准库中的iostream和string头文件,展示了如何使用for循环迭代字符串中的每个字符并进行替换。
427

被折叠的 条评论
为什么被折叠?



