Study (etc)/Problem Solving

[BOJ / C++] 26545번 : Mathematics

Haren 2022. 12. 20. 20:11

문제

A mathematician has stolen your calculator! Luckily, you know how to code and can write a program that adds together numbers. Write a program that adds together a list of integers.

입력

The first line will contain a single integer n that indicates the number of integers to add together. The next n lines will each contain one integer. Your task is to write a program that adds all of the integers together.

출력

Output the resulting integer. The output should be one line containing one integer value.

Solved.ac 레벨

브론즈 V

풀이

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, sum = 0;
    cin >> n;

    while(n--){
        int input;
        cin >> input;
        sum += input;
    }

    cout << sum << "\n";

    
    return 0;
}

 

 

26545번: Mathematics

A mathematician has stolen your calculator! Luckily, you know how to code and can write a program that adds together numbers. Write a program that adds together a list of integers.

www.acmicpc.net