본문 바로가기
카테고리 없음

백준 문제 풀이 10951번 {A+B -4}

by 토끼여우 2022. 2. 13.
728x90
SMALL
#include <iostream>
using namespace std;

int main(int argc, char const* argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int A, B;
	while (!(cin >> A >> B).eof()) {
		cout << A + B << '\n';
	}
	
	return 0;
}

  ios_base::sync_with_stdio(false); 로 동기화를 해제시키고

cin.tie(NULL); 를 해서 막은후

A,B를 선언하고

while 반복문을 돌려서 입력 eof(End of File) 함수로 파일이 끝날때 중지시키고

A+B를 출력하여 A,B를 입력할때 마다 합이 출력되게 한다

eof() 함수대신 fail() 함수를 사용하여도 된다

eof(),fail() 함수가 무엇이고 어떻게 쓰는지 모르겠다면 구글에 검색하여 이해하실바랍니다

 

728x90
LIST