반응형
https://www.acmicpc.net/problem/7891
7891번: Can you add this?
The input contains several test cases. The first line contains and integer t (t ≤ 100) denoting the number of test cases. Then t tests follow, each of them consisiting of two space separated integers x and y (−109 ≤ x, y ≤ 109).
www.acmicpc.net
간단한 구현 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
1. test case t를 선언 후 입력받습니다. 2. while loop를 t만큼 수행하며 지역변수 a, b를 선언해 입력받습니다.
📔 풀이과정
범위가 -10억 ~ 10억이므로 두 수를 더했을 때 int범위를 초과하지 않습니다.
📔 정답출력
a + b를 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int t;
int main(){
cin >> t;
while(t--){
int a, b;
cin >> a >> b;
cout << a + b << '\n';
}
}
'Algorithm > Implementation' 카테고리의 다른 글
(Python) - 백준(BOJ) 24309 : РАВЕНСТВО (2) | 2022.01.23 |
---|---|
(C++) - 백준(BOJ) 7947 : Koncert (0) | 2022.01.21 |
(C++) - 백준(BOJ) 7789 : 텔레프라임 (0) | 2022.01.19 |
(C++) - 백준(BOJ) 7598 : Bookings (0) | 2022.01.17 |
(C++) - 백준(BOJ) 7595 : Triangles (0) | 2022.01.16 |