这篇文章主要介绍了华为机试题之统计单词个数实例代码的相关资料,需要的朋友可以参考下
输入n个单词,统计各个单词出现的个数
#include #include <map> #include using namespac<em style="color:transparent">来源gao.dai.ma.com搞@代*码网</em>e std; int main() { map k; string word; while(cin>>word) ++k[word]; for(map::iterator i=k.begin();i!=k.end();i++) cout<<(*i).first<<"\t"<<(*i).second<<endl; return 0; }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
以上就是华为机试题之统计单词个数实例代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!