해맑은욱 2019. 9. 5. 16:50
*가장 큰 수(정렬 & 문자열) 
주어진 배열의 값들로 최대값 만들기. 
 
#include <iostream>
#include <string>
#include <vector>
 
using namespace std
 
bool compareNum(int a, int b) 
    string s1 = to_string(a); 
    string s2 = to_string(b); 
 
    return s1 + s2 > s2 + s1; 
 
string solution(vector numbers) { 
    string answer = ""
 
    sort(numbers.begin(), numbers.end(), compareNum); 
    for(auto elem : numbers) 
    { 
        answer += to_string(elem); 
    } 
 
    if(answer[0== '0'
        answer = '0'
 
    return answer; 
cs