본문 바로가기

프로그래머스/lv0

숫자 비교하기

/* 숫자 비교하기
 * 정수 num1과 num2가 매개변수로 주어집니다.
 * 두 수가 같으면 1 다르면 -1을 retrun
 *
 * num1 num2    result
 * 2    3       -1
 * 11   11      1
 * 7    99      -1
 */
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class programmer_0_35 {
    static int a1 = 2static int b1 = 3
    static int a2 = 11static int b2 = 11
    static int a3 = 7static int b3 = 99
 
    public int solution(int num1, int num2) {
        int answer = 0;
 
        return num1 == num2 ? 1 : -1;
    }
    public static void main(String args[]){
        programmer_0_35 t = new programmer_0_35();
 
        System.out.println("---------------------------------------");
        System.out.println("result = " + t.solution(a1,b1));
        System.out.println("---------------------------------------");
        System.out.println("result2 = " + t.solution(a2,b2));
        System.out.println("---------------------------------------");
        System.out.println("result3 = " + t.solution(a3,b3));
        System.out.println("---------------------------------------");
    }
}
cs

'프로그래머스 > lv0' 카테고리의 다른 글

최빈값 구하기  (1) 2022.12.05
두 수의 나눗셈  (0) 2022.12.05
배열 두배 만들기  (0) 2022.12.05
중앙값 구하기  (0) 2022.12.05
짝수는 싫어요  (0) 2022.12.05