두 정수를 붙여 쓴 값1 [프로그래머스][C++] 두 수의 연산값 비교하기 #include #include using namespace std; int solution(int a, int b) { int answer = 0; int i = b; int j = 2 * a * b; while(b > 0) { // b의 자릿수에 따라 a에 10을 곱하는 횟수가 정해짐 b /= 10; a *= 10; } i += a; // 최종 i = [a x {10^(b의 자릿수)}] + b answer = i >= j ? i : j; return answer; } #include #include #include using namespace std; int solution(int a, int b) { int answer = 0; int i = b + (a * pow(10, to_string(b).s.. 2023. 10. 25. 이전 1 다음