题目链接
题目大意
统计数字的个数
思路
使用STL map 的特性统计数字。
输入与输出样例
输入
8
2
4
2
4
5
100
2
100
输出
2 3
4 2
5 1
100 2
AC代码
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<map>
#include<stack>
using namespace std;
map<int,int>mp;
int main(int argc, char* argv[])
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
int a;
scanf("%d", &a);
mp[a]++;
}
for (auto it : mp)
{
cout << it.first << " " << it.second << endl;
}
return 0;
}