티스토리 뷰
1. Java 구현
import java.util.Scanner; public class Main { public static void main(String[] args) { /* 2018.08.08 */ Scanner sc = new Scanner(System.in); String input = getInput(sc); String num1 = splitInput(input, 0); String num2 = splitInput(input, 1); String result = getResult(num1, num2); printResult(result); } public static String getInput(Scanner sc) { return sc.nextLine(); } public static String splitInput(String str, int idx) { return str.split(" ")[idx]; } public static String getResult(String num1, String num2) { String max = ""; for(int i = num1.length() - 1; i >= 0; i--) { if(num1.charAt(i) > num2.charAt(i)) { return num1; } else if (num1.charAt(i) < num2.charAt(i)) { return num2; } } return max; } public static void printResult(String str) { for(int i = str.length() - 1; i >= 0; i--) { System.out.print(str.charAt(i)); } } }
'알고리즘 > BaekJoon 알고리즘' 카테고리의 다른 글
[백준 알고리즘] Q2941 크로아티아 알파벳 (0) | 2018.10.11 |
---|---|
[백준 알고리즘] Q5622 다이얼 (0) | 2018.10.11 |
[백준 알고리즘] Q1152 단어의 개수 (0) | 2018.10.11 |
[백준 알고리즘] Q1316 그룹 단어 체커 (0) | 2018.10.11 |
[백준 알고리즘] Q1157 단어공부 (0) | 2018.10.11 |