You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
526 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
string a[N];
bool cmp(const string &a, const string &b) {
//自定义排序函数这一步非常巧妙假设a=321b=32a+b=32132b+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;
}