ALGORITHM ๐Ÿค–/Baekjoon

๋ฐฑ์ค€ - 11021

daxx0ne 2023. 3. 8. 09:35

https://www.acmicpc.net/problem/11021

 

11021๋ฒˆ: A+B - 7

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค "Case #x: "๋ฅผ ์ถœ๋ ฅํ•œ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฒˆํ˜ธ๋Š” 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.

www.acmicpc.net

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] arr = new int[t]; // t๋งŒํผ ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ์ง€์ •
        int i = 0;
        while (i < t) { // t๋งŒํผ ๋ฐ˜๋ณต
            int a = sc.nextInt();
            int b = sc.nextInt(); // a, b๋ฅผ ์ž…๋ ฅ๋ฐ›์•„์„œ
            arr[i] = a + b; // ๋”ํ•œ ๊ฒƒ์„ ๋ฐฐ์—ด์— ์ฐจ๊ณก์ฐจ๊ณก ์ €์žฅ
            i++;
        }
        sc.close();

        int number = 1;
        for (int k : arr) { // ๋ฐฐ์—ด์˜ ์š”์†Œ๋ฅผ ํ•˜๋‚˜์”ฉ ์ถœ๋ ฅ
            System.out.printf("Case #%d: "+ k + "\n", number);
            number++;
        }
    }
}โ€‹