본문 바로가기
(문제풀이)

프로그래머스(java) : 숫자 비교하기

by cogito-new 2022. 10. 9.

class Solution {
    public int solution(int num1, int num2) {
        int answer = 0;
        if(num1 == num2){
            answer = 1;
        } else {
            answer = -1;
        }
        
        
        return answer;
    }
}

if로 비교한 문제.

반응형