map 迭代器的遍历
来源:互联网 发布:大数据徐子沛在线阅读 编辑:程序博客网 时间:2024/05/22 09:42
#include<map>#include<string>#include<iostream>#include<stdio.h>using namespace std;map<string ,int >cnt;map<string,int>::iterator it;int main(){ string s; int n; string ans; int maxn = 0; cin>>n; for(int i =0; i < n;i++) { cin>>s; if(!cnt.count(s))cnt[s] = 1; else cnt[s]++; } for(it= cnt.begin();it != cnt.end();it++) { if(it->second>maxn) { maxn= it->second; ans =it->first; } } cout<<maxn<<endl; cout<<ans<<endl; return 0;}
通过以上的测试,直接可以输出来第一个和第二个变量的值
这个代码是求得输入的最多的字符串 并且输出次数
阅读全文
0 0
- map 迭代器的遍历
- 【Map】Map集合的遍历:
- 关于map的遍历
- Map的遍历
- 对map的遍历
- map 的遍历
- Jquery的map遍历
- Map的遍历
- 对map的遍历
- Map的遍历方法
- java map 的遍历
- map的遍历方法
- Map的遍历方式
- map的遍历方法
- java Map 的遍历
- 容器Map的遍历
- Map的遍历方法
- Map的遍历方法
- D
- bottle嵌入html,css,js
- 私有构造函数(某位大神的讲解)
- Git与github的使用
- 8月18日训练笔记
- map 迭代器的遍历
- springMVC详解(上)
- 质数
- 常用加密 以及解密方法(包含测试方法) DES Base64 AES
- 51Nod 1686(第K大区间)
- [编程题] 堆棋子
- 斐波那契数列
- 图的基本存储的基本方式一(邻接矩阵)
- CodeForces