웅재의 코딩세상
[프로그래머스] 문자열 정수의 합 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(string num_str) {
int answer=0;
for(int i=0; i< num_str.size(); i++){
answer += num_str[i]-'0';
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 마지막 두 원소 (0) | 2024.01.26 |
---|---|
[프로그래머스] 할 일 목록 (0) | 2024.01.25 |
[프로그래머스] 배열의 원소만큼 추가하기 (0) | 2024.01.25 |
[프로그래머스] 뒤에서 5등까지 (1) | 2024.01.25 |
[프로그래머스] 순서 바꾸기 (0) | 2024.01.25 |