欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

華為機(jī)試題之統(tǒng)計(jì)單詞個(gè)數(shù)實(shí)例代碼

 更新時(shí)間:2017年05月16日 08:44:59   投稿:lqh  
這篇文章主要介紹了華為機(jī)試題之統(tǒng)計(jì)單詞個(gè)數(shù)實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下

輸入n個(gè)單詞,統(tǒng)計(jì)各個(gè)單詞出現(xiàn)的個(gè)數(shù)

#include <iostream> 
#include <map> 
#include <string> 
using namespace std; 
 
int main() 
{ 
  map<string,int> k; 
  string word; 
 
  while(cin>>word) 
    ++k[word]; 
 
  for(map<string,int>::iterator i=k.begin();i!=k.end();i++) 
    cout<<(*i).first<<"\t"<<(*i).second<<endl; 
 
  return 0; 
} 

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論