[HDOJ] problem_1004 【Let the Balloon Rise】

来源:互联网 发布:广州 深圳 知乎 编辑:程序博客网 时间:2024/06/09 01:36

[HDOJ] problem_1004 【Let the Balloon Rise】:

点击打开链接

#include<iostream>#include<cstdio>#include<map>#include<string>using namespace std;int main(){int i,j,n,t,max;string maxs,str;map<string,int> mp;map<string,int>::iterator it;while (scanf("%d",&t)!=EOF){mp.clear();if (!t)continue;for (i=1;i<=t;i++){cin>>str;mp[str]++;}max=0;for (it=mp.begin();it!=mp.end();it++){if (max<it->second){max=it->second;maxs=it->first;}}cout<<maxs<<endl;}return 0;}

这是我第一道用map解决的问题。学长之前讲了一下,似懂非懂。后来网上查了map的用法,琢磨了别人的代码,总算看懂了那么一点点,哈哈,还是把这道题A了!

发篇博客,鼓励自己一下哈哈

0 0