2020. 5. 22. 00:01
두 번째로 큰 수를 출력하는 간단한 프로그램 (백준 10871 자바)
세 개의 수를 입력하면 그 중 두 번째로 큰 수를 구하는 프로그램이다. sorting을 할 때도 주로 이용되는 방법으로, 경우의 수를 나눈 후 숫자를 두 개씩 차례대로 비교해 더 큰 수가 결과값에 저장되도록 하면 된다. array나 tokenizer 없이 nextInt() 메소드와 if문을 이용해 간단하게 구현하였다. import java.util.*; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int s = 0; if(a>b){ if(b>c) s=b; else if(a>c..