21 lines
526 B
C++
21 lines
526 B
C++
|
|
#include <bits/stdc++.h>
|
|||
|
|
|
|||
|
|
using namespace std;
|
|||
|
|
|
|||
|
|
const int N = 30;
|
|||
|
|
string a[N];
|
|||
|
|
|
|||
|
|
bool cmp(const string &a, const string &b) {
|
|||
|
|
//自定义排序函数,这一步非常巧妙,假设a=321,b=32;a+b=32132,b+a=32321
|
|||
|
|
// 这样下面sort排下来就是32>321避免出现32132>32321的情况
|
|||
|
|
return a + b > b + a;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int main() {
|
|||
|
|
int n;
|
|||
|
|
cin >> n;
|
|||
|
|
for (int i = 1; i <= n; i++) cin >> a[i];
|
|||
|
|
sort(a + 1, a + 1 + n, cmp);
|
|||
|
|
for (int i = 1; i <= n; i++)cout << a[i];
|
|||
|
|
return 0;
|
|||
|
|
}
|