문제 링크: https://www.acmicpc.net/problem/1330
백준 조건문 1단계 - 1330번 두 수 비교하기를 풀어보았다.
풀이: 두 수를 비교해 비교값을 출력한다. 두 수가 같으면 ==를 출력하는 것을 명심하자.
C++
#include <iostream>
using namespace std;
int main() {
int A, B;
cin>>A>>B;
if(A>B)
{
cout<<">";
}
else if(A<B)
{
cout<<"<";
}
else if(A==B)
{
cout<<"==";
}
}
Python
a,b=map(int,input().split())
if(a>b): print('>')
elif(a<b): print('<')
else: print("==")
Java
import java.util.Scanner;
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("==");
}
}
'코테용 문제풀이 > 백준' 카테고리의 다른 글
윤년 풀이 (0) | 2022.12.30 |
---|---|
시험 성적 풀이 (0) | 2022.12.30 |
새싹 풀이 (0) | 2022.12.30 |
개 풀이 (0) | 2022.12.30 |
고양이 풀이 (0) | 2022.12.30 |