首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

【地图热手题】HDU 1004—Let the Balloon Rise

2013-01-26 
【map热手题】HDU 1004—Let the Balloon Rise题目:点击打开链接建议初学STL的人用MAP来切这道水题,可以对MAP

【map热手题】HDU 1004—Let the Balloon Rise

题目:点击打开链接

建议初学STL的人用MAP来切这道水题,可以对MAP的方便之处有更加深刻的理解。

因为调用和查找的确挺简单的。效率据查阅资料,是lgN.

#include <iostream>#include <map>#include <string>using namespace std;int main(){int ballnum;while(cin>>ballnum && ballnum!=0){string temp;int bigger=0;map<string,int> balloon;for(int i=0;i<ballnum;i++){cin>>temp;balloon[temp]++;}map<string,int>::iterator it;for(it=balloon.begin();it!=balloon.end();it++){if((*it).second>bigger){bigger=(*it).second;}}for(it=balloon.begin();it!=balloon.end();it++){if((*it).second==bigger){cout<<(*it).first<<endl;}}}return 0;}


热点排行