-- 예전 기록/BOJ

[ BOJ ] 1001 : A-B ( BRONZE 5 ) / C, C++, Python, Java

rejo 2023. 5. 31. 15:42

문제

두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 A와 B가 주어진다. (0 < A, B < 10)

출력

첫째 줄에 A-B를 출력한다.

풀이 과정

정수 두 개를 입력받고 두 수의 차를 출력하는 문제이다.

언어의 입출력 규정에 맞게 코드를 작성하자.

C

#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d", a - b);
	return 0;
}

C++

#include <iostream>
using namespace std;

int main(void) {
    int a, b; cin >> a >> b;
    cout << a - b;
    return 0;
}

Python

a, b = map(int, input().split())
print(a-b)

Java

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();
        System.out.println(a-b);
    }
}