코딩테스트/프로그래머스
[Level 1][C++] 자릿수 더하기
MJ.Lee
2024. 9. 30. 20:50
#include <iostream>
#include <string>
#include <numeric>
using namespace std;
int solution(int n)
{
string s = to_string(n);
int answer = accumulate(s.begin(), s.end(),0)-'0'*s.size();
// [실행] 버튼을 누르면 출력 값을 볼 수 있습니다.
cout << "Hello Cpp" << endl;
return answer;
}