The Department of Redundancy Department
Write a program that will remove all duplicates from a sequence of integers and print the list of uniqueintegers occuring in the input sequence, along with the number of occurences of each.
Input
The input file will contain a sequence of integers (positive, negative, and/or zero). The input file maybe arbitrarily long.
Output
The output for this program will be a sequence of ordered pairs, separated by newlines. The firstelement of the pair must be an integer from the input file. The second element must be the numberof times that that particular integer appeared in the input file. The elements in each pair are to beseparated by space characters. The integers are to appear in the order in which they were containedin the input file.
Sample Input
3 1 2 2 1 3 5 3 3 2
Sample Output
3 4
1 2
2 3
5 1
问题简述:统计数的出现次数,按数出现的顺序输出那个数和出现的次数。
程序说明:
使用map可以简单第进行统计,但是顺序无法保证。
使用vector来存储数出现的顺序。
1 #include <bits/stdc++.h>
2 using namespace std;
3 int main()
4 {
5 int x;
6 vector<int> v;
7 map<int,int> m;
8 while(cin>>x)
9 {
10 if(m.find(x)==m.end()){
11 m.insert(make_pair(x,1));
12 v.push_back(x);
13 }
14 else{
15 m[x]++;
16 }
17 }
18 for(int i=0;i<v.size();i++)
19 {
20 cout<<v[i]<<" "<<m[v[i]]<<endl;
21 }
22 }
The Department of Redundancy Department的更多相关文章
- uva 484 - The Department of Redundancy Department
已有的数据结构装不下数据,或者不能处理现有的数据,那就必须要思考其他的辅助手段,辅助结构: #include <cstdio> #include <map> #include ...
- 3ds Max File Format (Part 3: The department of redundancy department; Config)
Now we'll have a look at the Config stream. It begins like follows, and goes on forever with various ...
- TSQL Beginners Challenge 1 - Find the second highest salary for each department
很久以前准备写的系列文章,后来因为懒一直耽搁着,今天突然决定继续下去,于是有了这篇文章,很基础,但很常用.题目描述依然拷贝.简单来说就是找出个个部门薪水排名第二的人,排名相同的要一起列出来. Intr ...
- [SQL]LeetCode184. 部门工资最高的员工 | Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [SQL]LeetCode185. 部门工资前三高的员工 | Department Top Three Salaries
SQL 架构 Create table If Not Exists Employee (Id ), Salary int, DepartmentId int) Create table If Not ...
- LeetCode——Department Top Three Salaries(巧妙使用子查询)
The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...
- LeetCode——Department Highest Salary(花式使用IN以及GROUP BY)
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- MySQL测试题——开发公司人事管理系统,包括 Employee表 和 Department表
一.需求分析 我们的开发团队,计划开发一款公司人事管理软件,用于帮助中小型企业进行更加高效的人事管理.现在需要对数据库部分进行设计和开发,根据对需求和立项的分析,我们确定该数据库中最核心的两个表为员工 ...
- Mysql 设计超市经营管理系统,包括员工信息表(employee)和 员工部门表(department)
互联网技术学院周测机试题(二) 一.需求分析 为进一步完善连锁超市经营管理,提高管理效率,减少管理成本,决定开发一套商品管理系统,用于日常的管理.本系统分为商品管理.员工管理.店铺管理,库存管理等功能 ...
随机推荐
- 项目API接口鉴权流程总结
权益需求对接中,公司跟第三方公司合作,有时我们可能作为甲方,提供接口给对方,有时我们也作为乙方,调对方接口,这就需要API使用签名方法(Sign)对接口进行鉴权.每一次请求都需要在请求中包含签名信息, ...
- #2使用html+css+js制作网站教程 测试
#2使用html+css+js制作网站教程 测试 本系列链接 1 测试 1.1 运行 1.2 审查 1.3 审查技巧 1.4 其他 引言: 编写完代码后就要上机测试代码,获得用户体验,筛选bug 笔者 ...
- 晋升新一线的合肥,跨平台的.NET氛围究竟如何?
大伙可能不知道,2020年合肥已经成功晋升为新一线城市了.本文通过对目前合肥.NET招聘信息以及公众号的相关数据的分析来看下目前合肥.NET的大环境.就着2020中国.NET开发者峰会的顺利举行的东风 ...
- Macbook 安装Windows的完美教程
[原文](http://www.melodydance.top/mac-win.html) 1. 背景 Windows相对于Mac市场占有率更高,对很多人来说Windows使用起来更方便,以至于很多人 ...
- docker save 保存导出镜像
Docker保存镜像 tag 镜像 # 镜像打 tag 标签 # docker tag 镜像id/名 新名字 docker tag fce91102e17d tomcat01 commit 镜像 注意 ...
- 环境配置-Java-02-卸载
1.卸载程序 在windows程序与功能中卸载Java相关的两个程序 2.删除环境变量 在windows环境变量中删除JAVA_HOME.CLASSPATH 以及 PATH中的两条路径 3.查看是否卸 ...
- Angular入门到精通系列教程(11)- 模块(NgModule),延迟加载模块
1. 摘要 2. NgModule举例.说明 3. Angular CLI生成模块 4. 延迟加载模块 5. 总结 环境: Angular CLI: 11.0.6 Angular: 11.0.7 No ...
- Zabbix监控虚拟机服务-告警与自动恢复-模板化
上一篇文章测试了服务的告警与自动恢复:Zabbix监控虚拟机服务-告警与自动恢复 但是我是直接为某一个主机增加的监控项和触发器, 如果要让某一个自定义的监控项和触发器被很多机器共用,则需要创建模板 1 ...
- 前端面试准备笔记之JavaScript(04)
01. DOM的本质 xml是一种可扩展的标记性语言,可扩展就是可以描述任何结构的数据,他是一棵树,可以自定义标签,可以自己扩展. html也是一种特定的xml,他规定了一些标签的名称,结构与xml是 ...
- 网络编程中 TCP 半开连接和TIME_WAIT 学习
https://blog.csdn.net/chrisnotfound/article/details/80112736 上面的链接就是说明来 SO_KEEPALIVE 选项 为什么还需要 在应用层开 ...