[백준/ 10950번] A+B - 3 (Java)

2023. 12. 16. 11:39[ CodingTest ]/Baekjoon

문제

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

 

입력

 첫째 줄에 테스트 케이스의 개수 T가 주어진다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)

출력

각 테스트 케이스마다 A+B를 출력한다.

사진 출처 : 백준사이트 문제 10950번(하단 링크 참조)

풀이(소스 코드)

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int count = sc.nextInt();
		
		int first [] = null;
		first = new int[count];
		int second [] = null;
		second = new int[count];
		
		for (int i = 0; i < count; i++) {
			first[i] = sc.nextInt();
			second[i] = sc.nextInt();
		}
		
		for (int i = 0; i < count; i++) {
			int sum = first[i] + second[i];
			System.out.println(sum);
		}
		
	}
}

 

 

문제링크 : https://www.acmicpc.net/problem/10950

 

 

 

개인 공부 기록용입니다:)

728x90