백준 java 10951 반복문(A+B-4)

임명수·2023년 5월 5일
0

백준

목록 보기
11/31

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



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 IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        try {

            StringBuilder sb = new StringBuilder();
            StringTokenizer st;
            String str="";

            while( (str = br.readLine()) != null ) {
                st = new StringTokenizer(str, " ");
                if(st.hasMoreTokens()){
                    int a = Integer.parseInt(st.nextToken());
                    int b = Integer.parseInt(st.nextToken());
                    sb.append(a+b).append("\n");
                }else{
                    break;
                }
            }
            br.close();
            System.out.println(sb);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
profile
푸른영혼의별

0개의 댓글