매일코테

백준 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
반응형

'매일코테' 카테고리의 다른 글

백준 3단계 no.14  (0) 2022.07.20
백준 3단계 no.13  (0) 2022.07.20
백준 3단계 no.11  (0) 2022.07.20
백준 2441번  (0) 2022.07.20
백준 2439번  (0) 2022.07.20