hdu1004 map,迭代器
来源:互联网 发布:阿里云邮寄资料 编辑:程序博客网 时间:2024/06/06 07:22
说点感(废)想(话),不只是因为这个map,,只是突然觉得c++比想象中厉害。。
写java时候曾觉得c什么的好麻烦诶。。
题意就是找出出现次数最多的颜色
#include<stdio.h>#include<iostream>#include<map>#include<string>using namespace std;map<string,int> save;int main(){ int n,maxNum; while(scanf("%d",&n)!=EOF) { string maxColor,color; save.clear(); maxNum=-1; if(n==0)break; for(int i=1;i<=n;i++) { cin>>color; if(save.count(color)==0) { save.insert(pair<string,int>(color,1)); }else { save[color]++; } } map<string,int>::iterator ite; for(ite=save.begin();ite!=save.end();ite++) { if(ite->second>maxNum) { maxNum=ite->second; maxColor=ite->first; } } cout<<maxColor<<endl; } return 0;}
0 0
- hdu1004 map,迭代器
- hdu1004 map水题
- map的应用hdu1004
- HDU1004(STL-map)
- hdu1004(map容器)
- hdu1004 (map总结)
- STL ---Map hdu1004,1075,1263
- hdu1004(map的使用)
- hdu1004
- hdu1004
- HDU1004
- HDU1004
- hdu1004
- HDU1004
- hdu1004
- hdu1004
- hdu1004
- HDU1004
- 杭电 2602
- jersey实现rest实例之二
- Substring with Concatenation of All Words
- Swing JTable 详解
- 使用tmx地图
- hdu1004 map,迭代器
- [Python]win32com模块编程初探
- ios AFNetworking预期内容错误
- 石英表需适时送到维修店更换电池
- 几个主要软件调试方法及调试原则
- android:baselineAligned,baselineAlignedChildIndex,addStatesFromChildren
- HDU1695-GCD(数论-欧拉函数-容斥)
- Python学习28:类、实例的其它内建函数
- 北京seo 优化公司排名 首选网罗天下工作室