본문 바로가기
C++

[프로그래머스] 더 크게 합치기

by 띰쥬 2025. 8. 27.
728x90
반응형
SMALL

#include <string>
#include <vector>

using namespace std;

int solution(int a, int b) {
    int answer = 0;
    
    string tmp1 = to_string(a) + to_string(b);
    string tmp2 = to_string(b) + to_string(a);
    
    answer = stoi(tmp1) > stoi(tmp2) ? stoi(tmp1) : stoi(tmp2);
    
    return answer;
}

 

 

#include <string>
#include <vector>

using namespace std;

int solution(int a, int b) {
    return max(stoi(to_string(a) + to_string(b)),stoi(to_string(b) + to_string(a)));
}

728x90
반응형
LIST

댓글