백준 10950번 (A+B - 3, C++) [BAEKJOON]

문제

https://www.acmicpc.net/problem/10950

시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율
1 초 256 MB 220776 128173 107780 58.299%

두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)

출력

각 테스트 케이스마다 A+B를 출력한다.

예제 입력 1

plaintext
5
1 1
2 3
3 4
9 8
5 2

예제 출력 1

plaintext
2
5
7
17
7

알고리즘 분류

출처

비슷한 문제


접근 방법

심심해서 리스트로 작성했다.

통과된 코드

cpp
#include <iostream>
#include <list>

using namespace std;

list <pair<int, int>> tempList;
list <pair<int, int>>::iterator it;

pair<int, int> temp;

int main()
{
	int N;
	cin >> N;
	while (N > 0) {
		cin >> temp.first >> temp.second;
		tempList.push_back(temp);
		N--;
	}

	for (it = tempList.begin(); it != tempList.end(); it++) 
		cout << it->first + it->second << "\n";

	return 0;
}