1 # include <iostream> 2 # include <string> 3 # include <vector> 4 # include <algorithm> 5 using namespace std; 6 bool compare(string &a, string &b){ 7 return (a+b) > (b+a); 8 } 9 int main(){ 10 int n; 11 cin >> n; 12 vector<string> str(n,""); 13 for (int i =0;i<n;i++){ 14 cin >> str[i]; 15 } 16 sort(str.begin(), str.end(), compare); 17 string res; 18 for (auto c : str){ 19 res += c; 20 } 21 cout << res <<endl; 22 return 0; 23 }
测试数据
输入:
7
6
9
8
7
56
4
3
输出:
98765643