백준 11021(A+B-7)

한장민·2022년 5월 15일
0
post-thumbnail

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int t = Integer.parseInt(br.readLine());
		int[] arr = new int[t];
		
		for(int i = 0; i < t; i++) {
			String str = br.readLine();
			StringTokenizer st = new StringTokenizer(str, " ");
			
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			arr[i] = a+b;
		}
		
		for(int i = 0; i < arr.length; i++) {
			System.out.println("Case #" + (i+1) +": " + arr[i]);
		}
		
	}
}

앞서 해본 코딩테스트 문제와 유사했다. "Case#X"를 출력할 때 나는 println을 사용하여 출력했지만 printf를 사용하여 출력하는게 더 깔끔할 수도 있겠다고 생각했다.

profile
HAAN YJGB

0개의 댓글