본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 2908번 상수

by 현장 2022. 4. 18.

-Code

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        a = Integer.parseInt(new StringBuffer().append(a).reverse().toString());
        b = Integer.parseInt(new StringBuffer().append(b).reverse().toString());

        System.out.println(Math.max(a, b));
    }
}

숫자를 문자열로 바꾸어 뒤집는 부분이 파이썬과 다르게 어렵게 되어있어서 시간이 많이 걸렸습니다.