Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

Hennie

[백준] 10950번 : A+B - 3 (JAVA) 본문

BaekJoon/03. for문

[백준] 10950번 : A+B - 3 (JAVA)

헨니 2021. 4. 13. 23:13

 

QUESTION

www.acmicpc.net/problem/10950

 

10950번: A+B - 3

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

www.acmicpc.net

 

ANSWER

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int arr[][] = new int[t][2];
		int sum[] = new int[t];
		for(int i=0; i<t; i++) {
			for(int j=0; j<2; j++) {
				arr[i][j] = scan.nextInt();
			}
		}
		for(int i=0; i<t; i++) {
			sum[i] = arr[i][0] + arr[i][1];
			System.out.println(sum[i]);
		}
	}
}

 

RESULT

 

MEMO

굳이 배열을 쓰지 않아도 되지만 굳이 배열을 써서 풀어보았어요

편-안하잖아요!

'BaekJoon > 03. for문' 카테고리의 다른 글

[백준] 2742번 : 기찍 N (JAVA)  (0) 2021.04.14
[백준] 2741번 : N 찍기 (JAVA)  (0) 2021.04.14
[백준] 15552번 : 빠른 A+B (JAVA)  (0) 2021.04.14
[백준] 8393번 : 합 (JAVA)  (0) 2021.04.13
[백준] 2739번 : 구구단 (JAVA)  (0) 2021.04.13