成功源于积累----波爸

思想决定高度,行动决定成败!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

#include<iostream>
#include<string>
#include<map>
#include<fstream>

using namespace std;

int main()
{
 ifstream ifs("test.txt");
 map<string, int> M;
 map<string, int>::iterator iter;
 string t;
 while(getline(ifs, t))
 {
  M[t]++;
 }

 string maxStr;
 int max=0;
 for(iter = M.begin(); iter != M.end(); iter++)
 {
  if(iter->second > max)
  {
   maxStr = iter->first;
   max = iter->second;
  }
  
 }
 cout << maxStr << "   " << max << endl;
 system("pause");
 return 0;
}

posted on 2012-06-24 21:22  沙场醉客  阅读(702)  评论(0编辑  收藏  举报