题目
思路
该题是一道非常简单的送分题,只需要将每次出现的次数记录下来在输出就好,此处使用的是哈希表unordered_map
来进行存储。
代码
#include <iostream>
#include <unordered_map>
using namespace std;
int n;
int main() {
cin >> n;
getchar();
unordered_map<int, int>map;
int temp;
for (int i = 0; i < n; i++) {
cin>>temp;
map[temp]++;
cout << map[temp] << " ";
}
return 0;
}```