UVA10420 - List of Conquests
来源:互联网 发布:2008 科比 知乎 编辑:程序博客网 时间:2024/06/05 06:18
问题描述
输入国名和英文名,然后统计出每个国家人出现的次数并按国家排序。
思路
学习c++中的stl的map,从而能够将字符串和数值匹配起来(其中存入map中的字符串会按字典序进行排列)。
代码
#include <iostream>#include <map>#include <string>using namespace std;int main(){ int n; string s,a; map<string,int> m; map<string,int>::iterator it; cin>>n; for(int i=0;i<n;i++) { cin>>s; getline(cin,a); m[s]++; } for(it=m.begin();it!=m.end();it++) { cout<<it->first<<" "<<it->second<<endl; } return 0;}
0 0
- uva10420 - List of Conquests
- UVa10420 List of Conquests
- UVA10420-List of Conquests
- UVA10420 List of Conquests
- UVA10420 - List of Conquests
- 10420 - List of Conquests
- 10420 - List of Conquests
- 10420 - List of Conquests
- uva_10420-List of Conquests
- 10420 - List of Conquests
- 10420 - List of Conquests
- 10420 - List of Conquests
- 10420 - List of Conquests
- List of Conquests
- 10420 - List of Conquests
- uva List of Conquests
- UVa_10420 - List of Conquests
- 10420 - List of Conquests
- UVa1347/poj2677 - C - Tour(DP)
- Jtopo入门Demo
- TrueCrypt最好用的加密软件
- 面向对象程序设计上机练习六(类和对象)
- 数据分布未明确时的检验方法
- UVA10420 - List of Conquests
- javascript时间戳和日期字符串相互转换(json)
- MAC DMG 安装 image not recognized
- flask关于请求方法
- 初学者笔记
- 读模式与写模式
- 【C语言】比较两个数组中是否有相同的元素
- 64位ubuntu kylin 16.04下制作tiny4412可用的SD启动卡
- 实验二——任务三——理解Task