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
'문제 풀이' 카테고리의 다른 글
[백준] 2753번: 윤년 - JAVA (자바) (0) | 2023.01.16 |
---|---|
[백준] 9498번: 시험 성적 - JAVA (자바) (0) | 2023.01.15 |
[백준] 10171번: 고양이 - JAVA (자바) (0) | 2023.01.15 |
[백준] 2588번: 곱셈 - JAVA (자바) (0) | 2023.01.12 |
[백준] 3003번: 킹, 퀸, 룩, 비숍, 나이트, 폰 - JAVA (자바) (0) | 2023.01.10 |