#include<bits/stdc++.h>
using namespace std;
int arr[100000];
int ans[100000];
int a=0,b=0;
int main()
{
while(cin>>a)
{
int num=0;
for(int i=0;i<a;i++)
{
cin>>arr[i];
}
sort(arr,arr+a,greater<int>());
for(int i=0;i<=9;i++)
{
for(int j=0;j<a;j++)
{
if(arr[j]%10==i)
{
ans[num]=arr[j];
num+=1;
}
}
}
for(int i=0;i<a;i++)
{
cout<<ans[i]<<" ";
}
cout<<'\n';
}
return 0;
}
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up