⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 map_output.cpp

📁 一个很好的贝叶斯分类器
💻 CPP
字号:

#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -