经典桶排序的题目!
八谈,直接上代码:

#include<iostream>
using namespace std;

int a[100050] = { 0 };
int x;

int main()
{
    int n;
    cin >> n;

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a[x]=1;
    }

    for (int i = 0; i < 100050; i++)
    {
        if (a[i]==1) ans++;
    }

    cout << ans << endl;

    for(int i=0;i<100050;i++)
        for (int j = 0; j < a[i]; j++)
        {
            cout << i << " ";
        }

    return 0;
}