알고리즘/BaekJoon
[c++] 11720번 : 숫자의 합
__jhp_+
2022. 3. 12. 14:34
https://www.acmicpc.net/problem/11720
11720번: 숫자의 합
첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다.
www.acmicpc.net
#include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int N = 0;
char strNum[101] = { 0, };
int nSum = 0;
cin >> N >> strNum;
int index = 0;
for (int i = 0; i < N; ++i)
{
nSum += strNum[i] - '0';
}
cout << nSum;
return 0;
}