백준 1330번 두 수 비교하기

2020. 4. 25. 19:09자료구조와 알고리즘

문제

두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오.

입력

첫째 줄에 A와 B가 주어진다. A와 B는 공백 한 칸으로 구분되어져 있다.

출력

첫째 줄에 다음 세 가지 중 하나를 출력한다.

  • A가 B보다 큰 경우에는 '>'를 출력한다.
  • A가 B보다 작은 경우에는 '<'를 출력한다.
  • A와 B가 같은 경우에는 '=='를 출력한다.
import java.util.Scanner;

public class al1330 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (a > b) {
			System.out.println(">");
		} else if (a < b) {
			System.out.println("<");
		} else {
			System.out.println("==");
		}
	}

}

 

'자료구조와 알고리즘' 카테고리의 다른 글

백준 14681번 사분면 고르기  (0) 2020.04.26
백준 2753번 윤년  (0) 2020.04.26
백준 9498번 시험 성적  (0) 2020.04.25
백준 10430번  (0) 2020.04.25
백준 10869번  (0) 2020.04.25