문제 풀이

[백준] 1330번: 두 수 비교하기 - JAVA (자바)

auyeol 2023. 1. 15. 18:38
728x90

 

문제

 

https://www.acmicpc.net/problem/1330

 

1330번: 두 수 비교하기

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

www.acmicpc.net

두 정수를 입력을 받은 뒤, 두 수를 비교하여 print하는 문제이다.

 

 

 

풀이

 

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a<b) System.out.println("<");
		else if(a>b) System.out.println(">");
		else System.out.println("==");
			
		sc.close();
		
	}	
}

 

a가 b보다 큰 경우(a>b)           →   "<" 출력 

 

a가 b보다 작은 경우(a<b)        →   ">" 출력

 

그 외 (==)인 경우                      →  "==" 출력

728x90