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的更多相关文章

  1. uva 484 - The Department of Redundancy Department

    已有的数据结构装不下数据,或者不能处理现有的数据,那就必须要思考其他的辅助手段,辅助结构: #include <cstdio> #include <map> #include ...

  2. 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 ...

  3. TSQL Beginners Challenge 1 - Find the second highest salary for each department

    很久以前准备写的系列文章,后来因为懒一直耽搁着,今天突然决定继续下去,于是有了这篇文章,很基础,但很常用.题目描述依然拷贝.简单来说就是找出个个部门薪水排名第二的人,排名相同的要一起列出来. Intr ...

  4. [SQL]LeetCode184. 部门工资最高的员工 | Department Highest Salary

    The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...

  5. [SQL]LeetCode185. 部门工资前三高的员工 | Department Top Three Salaries

    SQL 架构 Create table If Not Exists Employee (Id ), Salary int, DepartmentId int) Create table If Not ...

  6. LeetCode——Department Top Three Salaries(巧妙使用子查询)

    The Employee table holds all employees. Every employee has an Id, and there is also a column for the ...

  7. 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 ...

  8. MySQL测试题——开发公司人事管理系统,包括 Employee表 和 Department表

    一.需求分析 我们的开发团队,计划开发一款公司人事管理软件,用于帮助中小型企业进行更加高效的人事管理.现在需要对数据库部分进行设计和开发,根据对需求和立项的分析,我们确定该数据库中最核心的两个表为员工 ...

  9. Mysql 设计超市经营管理系统,包括员工信息表(employee)和 员工部门表(department)

    互联网技术学院周测机试题(二) 一.需求分析 为进一步完善连锁超市经营管理,提高管理效率,减少管理成本,决定开发一套商品管理系统,用于日常的管理.本系统分为商品管理.员工管理.店铺管理,库存管理等功能 ...

随机推荐

  1. FastApi学习(二)

    前言 继续学习 此为第二篇, 还差些知识点就可以结束, 更多的比如用户的身份校验/ swagger 文档修改等以后会单独写 正文 使用枚举来限定参数 可以使用枚举的方式来限定参数为某几个值之内才通过 ...

  2. 常用 .gitignore 模板

    前言 每次建项目的时候可以直接复制了,也算是方便自己,以后发现少的会更新 正文 作用 git提交时忽略文件 文件名 .gitignore Python # Byte-compiled / optimi ...

  3. SpringBoot配置文件(2)

    六.配置文件加载 SpringBoot 启动会扫描以下位置的application.properties或者application.yml文件作为SpringBoot的默认配置文件 file:./co ...

  4. iostat的输出

    第一行显示的时子系统启动以来的平均值,接下来的报告显示了增量的平均值,每个设备一行 Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   ...

  5. P1341 无序字母对(欧拉回路)

    题目链接: https://www.luogu.org/problemnew/show/P1341 题目描述 给定n个各不相同的无序字母对(区分大小写,无序即字母对中的两个字母可以位置颠倒).请构造一 ...

  6. python—打开图像文件报错

    今天使用python打开一张图像文件的时候报错了 UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illeg ...

  7. vs code配置vue自动格式化

     vs code配置vue自动格式化 我他妈的要被这个vs code的格式化逼疯了.我在网上看了很多的文章,不是太老就是不好使,遇到太多坑了.在这贴出自己的配置,虽然有多余的代码,虽然可能在未来的更新 ...

  8. JavaScript学习总结(基础知识)

    js代码引入 方式1: <script> alert('欢迎来到德玛西亚!') </script> 方式2:外部文件引入 src属性值为js文件路径 <script sr ...

  9. 制作 Ubuntu 16.04 离线apt源

    1.下载离线安装包 ubuntu下安装包都会下载到/var/cache/apt/archives下,首先清空该目录 sudo apt-get clean 下载需要安装包 sudo apt-get in ...

  10. SpringCloud zuul 网关限流分析

    最近项目中 spring cloud zuul 运用到限流功能,打算配置一下就直接使用,不过在压测与调优过程中遇到一些没有预测到的问题,附上排查与解析结果 yml.pom配置 强烈推荐,按最新gith ...