c++ 从一个文本文件读取正文,统计每个数字出现的次数和其他字符出现的次数。要求有设计报告及流程图

c++ 不是c语言的,带流程图
2025-02-22 09:30:26
推荐回答(2个)
回答1:

从配置文本里面用fgets读取数据
读一行然后寻找出现的字符的次数
记下来然后然后累加!直到读完最后一行!

回答2:

#include
#include
#include
#include
using std::map;
using std::ifstream;
using std::cout;
using std::isdigit;
int main()
{
map count;
map else_char;
ifstream oo("filename.txt");
char temp;
while (!oo.eof()) {
oo.get(temp);
if(isdigit(temp)) count[temp]++;
else else_char[temp]++;
}
return count.size();
}