본문 바로가기
Algorithm/BaekJoon[Java]

백준 10950

by 씨니 2022. 3. 16.
728x90

 

▶1번째

import java.util.*;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		
		int arr[] = new int[num];
		
		for(int i = 0; i < num; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			
			arr[i] = A+B;
		}
		
		/*for(int j = 0; j < num; j++) {
			System.out.println(arr[j]);
		}*/
		for(int sum : arr) {
			System.out.println(sum);
		}
    }
}

 

▶2번째

import java.util.*;

public class Main {
	public static void main(String[] args){
    
    	Scanner sc = new Scanner(System.in);
	    int t = sc.nextInt();
	    int a, b;
        
	    for(int i = 0 ; i < t ; i++) {
	    	a = sc.nextInt();
	        b = sc.nextInt();
	        System.out.println(a+b);
	    }
        
	}
}
728x90

'Algorithm > BaekJoon[Java]' 카테고리의 다른 글

백준 10953(문자열 콤마(') 구분)  (0) 2022.03.16
백준 10952  (0) 2022.03.16
백준 10951  (0) 2022.03.16
백준 1000, 2558  (0) 2022.03.16
백준 2557(Input, Output문제)  (0) 2022.03.16