Baekjoon 11720
숫자의 합


QUESTION ❔



CODE ⌨️

#include <iostream>
#include <string>

using namespace std;

int N;
string s;
int sum = 0;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> N;
	cin.ignore();

	getline(cin, s);

	for (int i = 0; i < s.length(); i++)
	{
		sum += (int)s[i] - (int)'0';
	}

	cout << sum << "\n";

	return 0;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

문자열 관련 문제였다.



SOURCE 💎

Baekjoon_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.