hdoj 1004 Let the Balloon Rise(map)
2017-11-19 21:10
381 查看
Let the Balloon Rise(链接)
Sample Input5
green
red
blue
red
red
3
pink
orange
pink
0
Sample Output
red
pink
输出出现次数最多的颜色 用map存一下就好了
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> using namespace std; int main() { map<string,int> B; string Color,Max; int n; while(~scanf("%d",&n)&&n!=0) { B.clear(); while(n--) { cin>>Color; B[Color]++; } int max=0; map<string,int>::iterator it; //迭代器 for(it=B.begin();it!=B.end();it++) { if(it->second>max) { max=it->second; //只能用 -> 不可以用dian点. Max=it->first; } } cout<<Max<<endl; } return 0; }
相关文章推荐
- HDOJ 1004 Let the Balloon Rise (map)
- hdoj1004 Let the Balloon Rise(map)
- hdoj 1004 Let the Balloon Rise (map)
- HDOJ 1004 Let the Balloon Rise
- HDU - 1004 Let the Balloon Rise (map)
- HDU-1004 Let the Balloon Rise(map)
- hdu 1004 Let the Balloon Rise map
- HDOJ 1004 Letthe Balloon Rise (寻找最多的颜色)
- HDOJ-1004 Let the Balloon Rise
- HDU-#1004 Let the Balloon Rise(字符串+map)
- HDU 1004(map) Let the Balloon Rise
- HDOJ杭电1004 Let the Balloon Rise
- hdoj 1004 Let the Balloon Rise(模拟 || 字典树)
- map容器的应用:hdu 1004 Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise【Map】
- 渣渣ACM日记——1004-Let the Balloon Rise(HDOJ)
- 【hdu 1004】Let the Balloon Rise(map)
- hdoj1004--Let the Balloon Rise