代码
#include <bits/stdc++.h>
using namespace std;
int n , f = 1;
struct nn{
int a , b;
}q[21];
int ff(int p){
int s;
while(p){
s = p % 10;
p /= 10;
}
return s;
}
bool cmp(nn x ,nn y){
if(x.b > y.b)return 1;
else return 0;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin >> q[i].a;
}
while(1){
for(int i = 1;i <= n;i++){
q[i].b = ff(q[i].a);
}
sort(q+1,q+1+n,cmp);
if(q[1].a == 0)break;
cout << q[1].a;
q[1].a = 0;
}
return 0;
}