📖 Coding Study/Algorithm
백준 10952번 문제풀이
빵모루
2024. 1. 1. 18:53
처음 시도해본 코드
#include <iostream>
using namespace std;
int main() {
int A, B = 0;
while(!(A == 0 && B == 0)) {
cin >> A >> B;
cout << A + B << "\n";
}
return 0;
}
출력해보니 0 0 을 입력해도 0 + 0 의 값인 0이 결과로 출력되어서 실패한 듯 하다.
#include <iostream>
using namespace std;
int main() {
int A, B = 0;
while (true) {
cin >> A >> B;
if (A != 0 && B != 0) {
cout << A + B << "\n";
} else { break;}
}
return 0;
}
이렇게 바꿔서 제출했더니 성공했다.
LIST