Java
import java.util.Scanner;
class Main {
public static void main (String [] args ){
Scanner scan = new Scanner(System.in);
int A = scan.nextInt();
int B = scan.nextInt();
System.out.println(A + B);
System.out.println(A - B);
System.out.println(A * B);
System.out.println(A / B);
System.out.println(A % B);
}
}
- Scanner : 자바에서 가장 대표적인 숫자형성함수
scanner 함수 설명 : https://st-lab.tistory.com/92
Python
a, b = input().split()
a, b = int(a), int(b)
print(a+b)
print(a-b)
print(a*b)
print(a//b)
print(a%b)
- 파이썬은 java와 다르게 ; 가 필요없음
- 파이썬은 한 줄에 변수 N 개 사용 가능
- 자바는 /, 파이썬은 //
split 함수 설명 : https://study-all-night.tistory.com/104
한줄에 변수 2개 설정 : https://uhhyunjoo.tistory.com/20
'오답노트 > 백준알고리즘(Java&Python)' 카테고리의 다른 글
[백준 알고리즘 : 2557] Hello World 출력하기 (1) | 2024.11.19 |
---|---|
프로그래머스_신고결과받기(Java) (0) | 2022.05.17 |