시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 155916 | 106057 | 94347 | 68.748% |
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
첫째 줄에 테스트 케이스의 개수 T가 주어진다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다.
5
1 1
2 3
3 4
9 8
5 2
Case #1: 1 + 1 = 2
Case #2: 2 + 3 = 5
Case #3: 3 + 4 = 7
Case #4: 9 + 8 = 17
Case #5: 5 + 2 = 7
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a;
int b;
int num = 0;
ArrayList<Integer> arr = new ArrayList<>();
ArrayList<Integer> anum = new ArrayList<>();
ArrayList<Integer> bnum = new ArrayList<>();
for (int i = 1; i <= n; i++) {
a = sc.nextInt();
b = sc.nextInt();
arr.add(a+b);
anum.add((a));
bnum.add((b));
}
for (int i = 0; i < n; i++) {
num++;
System.out.println("Case #" +num +": "+anum.get(i)+" + "+bnum.get(i)+" = "+arr.get(i));
}
}
}