본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 18398 : HOMWRK

반응형

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

 

18398번: HOMWRK

In one of the beautiful cities of Afghanistan two sisters are going to program a simple game to help them solve their mathematics homework. Their homework asks them to calculate the sum and multiplication of two numbers. Your task is to help them to build

www.acmicpc.net

간단 구현 문제였습니다.

📕 풀이방법

📔 입력 및 초기화

간단 구현 문제였습니다.

📔 풀이과정

test case 수 t, 문제 수 n, 각 문제의 점수 a, b를 선언 후 적절히 입력받습니다.

📔 정답출력

a+b와 a*b값을 형식에 맞춰 출력합니다.


📕 Code

#include <bits/stdc++.h>
using namespace std;
int t, n, a, b;
int main(){
    cin >> t;
    while(t--){
        cin >> n;
        while(n--){
            cin >> a >> b;
            cout << a + b << ' ' << a * b << '\n';
        }
    }
}

*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.