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++;
}
}
}โ