๐Ÿ•ธ Algorithm/๐Ÿ•ธ ๋ฐฑ์ค€ BaekJoon

[๋ฐฑ์ค€][java][10952][A+B - 5]

๋‰ด์ด NUEY 2023. 10. 9. 23:33
๋ฐ˜์‘ํ˜•

import java.util.Scanner;

public class Main {
	// 10952 A+B - 5
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int sum = a+b;
			
			if (sum == 0) {
				sc.close();
				break;
			}
			
			System.out.println(sum);
		}
	}
}

์ž…๋ ฅ๋œ ์ˆ˜์˜ ํ•ฉ์ด 0์ผ ๊ฒฝ์šฐ break;์œผ๋กœ while()๋ฌธ์„ ๋ฒ—์–ด๋‚˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ฐ˜์‘ํ˜•