728x90
바로가기 : JAVA 풀이 C언어 풀이 Python 풀이
링크 : https://www.acmicpc.net/problem/10951
문제
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력
입력은 여러 개의 테스트 케이스로 이루어져 있다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력
각 테스트 케이스마다 A+B를 출력한다.
예제 입력 1
1 1
2 3
3 4
9 8
5 2
예제 출력 1
2
5
7
17
7
JAVA 풀이
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + b);
}
}
}
C언어 풀이
#include <stdio.h>
int main()
{
int a, b;
while(scanf("%d %d", &a, &b) != EOF){
printf("%d\n", a + b);
}
return 0;
}
Python 풀이
while True:
try:
a, b= map(int,input().split())
print(a + b)
except:
break
728x90