map_output.cpp
来自「一个很好的贝叶斯分类器」· C++ 代码 · 共 52 行
CPP
52 行
#include "stdafx.h"
#include"BeyesClassifier.h"
void map_output( map<string, int> *text_map )
{
string ofile("3_1_1out.txt");
ofstream outfile( ofile.c_str() );
if (!outfile)
{
cerr << "error: unable to open output file: "
<< ofile << endl;
}
map< string, int >::iterator map_siter = text_map->begin();
for ( ; map_siter != text_map->end(); ++map_siter )
{
outfile << (*map_siter).first;
for ( int n = 0; n < 15 - (*map_siter).first.size(); ++n )
{
outfile << ' ';
}
outfile << "出现 " << (*map_siter).second << "\t次" << endl;
} // end of for
cout << "程序已将处理结果写入3_1_1out.txt,该文件保存在当前目录"
<< endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?