最大组合的数

 

 

 代码:

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int Comp(string a, string b)
{
    return a+b>b+a;
}

int main()
{
    int numCnt = 0;
    cin>>numCnt;
    while(numCnt--) {
        int m;
        cin>>m;
        int temp;
        vector<string> num;
        for(int i = 0;i< m; i++)
        {
            cin>>temp;
            num.push_back(to_string(temp));
        }
        sort(num.begin(),num.end(),Comp);
        for(auto i : num){
            cout<<i;
        }
        cout<<endl;
    }
    return 0;
}

 

posted @ 2022-02-24 09:34  A-inspire  Views(38)  Comments(0Edit  收藏  举报