[BOJ] 1330번 두 수 비교하기

나르·2020년 12월 31일
0

알고리즘

목록 보기
2/15

백준#1330 두 수 비교하기 (https://www.acmicpc.net/problem/1330)

코드 - Python

a,b = map(int, input().split())
if a>b :
    print(">")
elif a==b:
    print("==")
else: print("<")

코드 - Java

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);

        System.out.println((a>b) ? ">" : ((a < b) ? "<" : "=="));
    }
}

삼항연산자를 이용하면 깔끔한 코딩이 가능하다.

profile
💻 + ☕ = </>

0개의 댓글