(구) solved ac class 문제들/class 1
[class 1]백준 A+B - 5(10952번) (C++/Python)
isekaipudding
2026. 2. 15. 11:06
문제 : A+B - 5(10952번)(Bronze V)
문제 링크 : https://www.acmicpc.net/problem/10952
출처 : Baekjoon Online Judge
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
while(true) {
int a, b;
cin >> a >> b;
if(a == 0 && b == 0) break;
cout << a + b << '\n';
}
return 0;
}
while문 안에 true를 넣으면 항상 참이 되어 무한 루프가 됩니다.
그러나 a와 b가 둘 다 0인 경우 break를 통해 탈출할 수 있습니다.
import sys
input = sys.stdin.readline
while True :
A, B = map(int, input().split())
if A == 0 and B == 0 :
break
print(A + B)
이것도 마찬가지로 while true를 통해 무한 루프를 구현해서 A, B가 모두 0인 경우에만 탈출하고 나머지 경우는 A+B 연산을 합니다.