(구) solved ac class 문제들/class 1

[class 1]백준 두 수 비교하기(1330번) (C++/Python)

isekaipudding 2026. 2. 3. 12:45

문제 : 두 수 비교하기(1330번)(Bronze V)

문제 링크 : https://www.acmicpc.net/problem/1330
출처 : Baekjoon Online Judge

 

조건문 기초에서 if문 등에 대해 간단히 알 수 있습니다.

바로 정답 소스 코드를 공유하도록 하겠습니다.

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b;
    cin >> a >> b;
    
    if(a > b) cout << ">";
    else if(a < b) cout << "<";
    else cout << "==";
 
    return 0;
}

참고로 조건문 혹은 반복문에서 실행할 코드가 단 한 줄이면 {} 생략 가능합니다.

Python의 경우 아래와 같이 작성하면 됩니다.

import sys

input = sys.stdin.readline

A, B = map(int, input().split())

if A > B :
    print(">")
elif A < B :
    print("<")
else :
    print("==")