You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
571 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int main() {
//录入数据到vector数组
int n;
cin >> n;
vector<int> vec;
for (int i = 0; i < n; i++) {
int c;
cin >> c;
vec.push_back(c);
}
//从第1个开始每一个向它前端找一样的数字然后加1就是本次出现的次数
for (int i = 0; i < n; i++) {
int count = 0;
for (int j = i; j >= 0; j--) {
if (vec[i] == vec[j])count++;
}
cout << count << " ";
}
return 0;
}