#include <iostream>
#include <string>
using namespace std;
// 字符串统计
int main()
{
string text;
string line;
int rows=0;
while(getline(cin,line)){
if(line=="q"){
break;
}
text += line + "\n";
rows++;
}
cout<<"Total Chars:"<<text.size()<<" Total Rows:"<<rows<<endl;
cout<<text<<endl;
return 0;
}
10003 字符统计
最新推荐文章于 2022-12-21 00:55:40 发布
本文介绍了一个使用C++实现的简单程序,该程序通过标准输入读取多行文本,统计并输出字符总数及行数,并展示原始输入内容。此程序利用了C++标准库中的字符串操作,展示了基本的文件处理技巧。

1万+

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



