728x90
A+B - 3
백준 온라인 저지 알고리즘 문제풀이
문제
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력
첫째 줄에 테스트 케이스의 개수 T가 주어진다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력
각 테스트 케이스마다 A+B를 출력한다.
코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a, b, t;
t = scan.nextInt();
int[] result = new int[t];
for (int i = 0; i < t; i++) {
a = scan.nextInt();
b = scan.nextInt();
result[i] = a + b;
}
scan.close();
for (int i = 0; i < t; i++) {
System.out.println(result[i]);
}
}
}