반응형
요약 : A와 B 입력 후 A+B의 값을 출력한다. 프로그램을 끝내는 조건문이 없으므로 while()에 조건문을 걸어두자.
소스코드
1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a,b;
while(cin >> a >> b) {
cout << a+b << endl;
}
return 0;
}
|
cs |
2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int a,b;
while(true) {
cin >> a >> b;
if(cin.eof()==true) break; //입력값이 없을 때
cout << a+b << endl;
}
return 0;
}
|
cs |
정답 확인
반응형
'category > 백준 알고리즘 c++' 카테고리의 다른 글
백준 알고리즘 2577번 숫자의 개수 c++ (0) | 2020.12.13 |
---|---|
백준 알고리즘 2562번 최대 c++ (0) | 2020.12.13 |
백준 알고리즘 10818번 최소, 최대 c++ (0) | 2020.12.13 |
백준 알고리즘 1110번 더하기 사이클 c++ (0) | 2020.12.04 |
백준 알고리즘 10952번 A + B - 5 c++ (0) | 2020.12.04 |
백준 알고리즘 10871번 X보다 작은 수 c++ (0) | 2020.12.04 |
백준 알고리즘 2439번 별 찍기 - 2 c++ (0) | 2020.12.04 |
백준 알고리즘 2438번 별 찍기 - 1 c++ (0) | 2020.12.04 |
댓글