프로그래머스 문제
두 수의 연산값 비교하기
nakgopsae
2024. 6. 12. 11:49
class Solution {
public int solution(int a, int b) {
int answer = 0;
String strA = Integer.toString(a);
String strB = Integer.toString(b);
String strAB = strA + strB;
int resultAB = Integer.parseInt(strAB);
int result2ab = 2*a*b;
if (resultAB>result2ab){
answer = resultAB;
} else if (resultAB<result2ab) {
answer = result2ab;
}else if(resultAB == result2ab){
answer = resultAB;
}
return answer;
}// 문자열 변환후 a+b와 2*a*b를 비교하여 답안작성
}