알고리즘/C++문제풀이

프로그래머스 / LV 0 / 두 수의 연산값 비교하기.

미역제자 2024. 9. 4. 22:07


#include <string>
#include <vector>

using namespace std;

int solution(int a, int b) {
    int answer = 0;
    string A = to_string(a);
    string B = to_string(b);
    string Answer1 = A + B;
    int K = 2 * a * b;
    if (stoi(Answer1) < K) {
        answer = K;
    }
    else
    {
        answer = stoi(Answer1);
    }
    return answer;
}

'알고리즘 > C++문제풀이' 카테고리의 다른 글

프로그래머스 / LV 0 / a와 b 출력하기  (0) 2024.09.02