记录每个出现的数字的次数,最后按出现次数的从小到大输出
const int N = 2e5 + 10;
int a[N];
int n; cin >> n;
for(int i = 1; i <= n; ++ i)
{
int x; cin >> x;
a[x] ++;
}
//假设数组内最大元素值不超过1e5
for(int i = 0; i < 1e5; ++ i)
for(int j = 0; j < a[i]; ++ j)
cout << i << ' ';
cout << endl;