题意:给n个数字,输出这些数字能组成的最大数字
题解:把数字作为字符串读入,排序时按两个连在一起较大的方式排序。
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 55;
string in[N];
int cmp(string a, string b) {
return a + b > b + a;
}
int main() {
int t;
while (cin >> t && t) {
for (int i = 0; i < t; i++)
cin >> in[i];
sort(in, in + t, cmp);
for (int i = 0; i < t; i++)
cout << in[i];
cout << endl;
}
return 0;
}