백준 11720 c++

magicdrill·2024년 4월 6일
0

백준 문제풀이

목록 보기
264/655

백준 11720 c++

#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(void)
{
	int N, total = 0;
	int temp;
	char* str = nullptr;

	cin >> N;
	if (N >= 1 && N <= 100)
	{
		str = new char[N + 1];
		cin >> str;
		for (int i = 0; i < N; i++)
		{
			temp = str[i] - '0';
			total = total + temp;
		}
	}
	else
	{
		;
	}
	cout << total << endl;

	delete[] str;

	return 0;
}

0개의 댓글