매일코테

백준 3단계 no.12

공주맛밤 2022. 7. 20. 13:15

import java.io.*;


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));

        while (true) {
            String a = br.readLine();
            String[] str = a.split(" ");

            if (Integer.parseInt(str[0])==0 && Integer.parseInt(str[1])==0) {
                break;
            } else {
                bw.write(Integer.parseInt(str[0])+Integer.parseInt(str[1])+"\n");
            }
        }
        bw.close();
    }
}

<오답>: 문제에서 한번에 값을 받고 출력한다는 점을 간과함

while (true) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            
            if (a==0 && b==0) {
                break;
            } else {
                System.out.print();
            }
        }

 

728x90
반응형