C++)
#include <iostream>
#include <string>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string str;
cin >> str;
int answer = 0;
for (auto ch : str) {
answer += (ch-'0');
}
cout << answer;
return 0;
}
Python)
import sys
read = sys.stdin.readline
n = read().rstrip()
arr = list(map(int, read().rstrip()))
print(sum(arr))'백준 1 > 기초' 카테고리의 다른 글
| [백준 10818] 최소, 최대 (C++/Python) (0) | 2020.12.05 |
|---|---|
| [백준 11721] 열 개씩 끊어 출력하기 (C++/Python) (0) | 2020.12.05 |
| [백준 11719] 그대로 출력하기2 (C++/Python) (0) | 2020.12.05 |
| [백준 11718] 그대로 출력하기 (C++/Python) (0) | 2020.12.05 |
| [백준 10951] A+B - 4 (C/Python) (0) | 2020.12.05 |