๋ฐ์ํ
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()๋ฌธ์ ๋ฒ์ด๋๋ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ผ๋ก ์ด์ฉํ์ต๋๋ค.
๋ฐ์ํ
'๐ธ Algorithm > ๐ธ ๋ฐฑ์ค BaekJoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][java][10807][๊ฐ์ ์ธ๊ธฐ] (0) | 2023.10.15 |
---|---|
[๋ฐฑ์ค][java][10951][A+B - 4] (0) | 2023.10.09 |
[๋ฐฑ์ค][java][2439][๋ณ ์ฐ๊ธฐ - 2] (0) | 2023.10.09 |
[๋ฐฑ์ค][java][2438][๋ณ ์ฐ๊ธฐ - 1] (0) | 2023.10.09 |
[๋ฐฑ์ค][java][11022][A+B - 8] (1) | 2023.10.08 |