알고리즘 풀이/백준
[백준][Java] 2908번 상수
배게
2018. 4. 20. 04:26
728x90
백의자리와 일의자리의 숫자를 교환하는 함수를 정의한 후
바뀐 두 숫자를 비교하여 높은 값 출력
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a,b; a=sc.nextInt(); b=sc.nextInt(); a=oToH(a); b=oToH(b); if(a>b) System.out.println(a); else System.out.println(b); } private static int oToH (int input) { int h,o; h=input/100; o=input%10; input-=(100*h+o); input+=(100*o+h); return input; } } |