알고리즘/백준(backjoon)

[Baekjoon]백준 NO.11021 - A+B-7 / Java(자바)

씨네 2021. 5. 9. 15:13
728x90

for문을 이해하고 있다면 누구나 풀수 있는문제입니다!

다만 예제 입력과 예제 출력에 맞게 출력에서 '띄어쓰기'도 잘보고 출력하셔야합니다!

컴퓨터는 똑똑하지만 멍청해서 유도리가 없거든요

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int test = sc.nextInt();
        
        int arr[] = new int[test];
        
        for(int i = 0; i< test;i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            arr[i] = a+b ; 
        }

        int x = 0;
        for(int j : arr) {
            x++;
            System.out.printf("Case #%d: %d \n",x,j);
        }

    }
}
728x90