[백준] - 단계별로 풀어보기(반복문) 11021

7316 단어 Java백준Java

백준 11021번

A+B -7

문제 출처 https://www.acmicpc.net/problem/11021


내가 작성한 코드

import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(br.readLine()); //int형 변환
		
		for(int i=1; i<=n; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			bw.write("Case #"+i+": "+ (Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken())) +"\n");
		}
		bw.flush();
		bw.close();
	}
}

BufferedReader / StringTokenizer / BufferedWriter 설명 참고

좋은 웹페이지 즐겨찾기