Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n, cmax = 0, v[10] = {}, aux;
cin >> n;
aux = n;
while(aux != 0)
{
if(cmax < aux%10) cmax = aux%10;
aux /= 10;
}
aux = n;
while(aux%10 != cmax)
{
v[aux%10]++;
aux /= 10;
}
for(int i = 0; i <= 9; i++)
{
while(v[i] > 0)
{
cout << i << " ";
v[i]--;
}
}
}