본문 바로가기

코딩테스트

프로그래머스_0단계_숨어있는 숫자의 덧셈 (1)C++

 

문제풀이:

#include <string>
#include <vector>

using namespace std;

int solution(string my_string) {
    int answer = 0;
    
    for(char c: my_string)
    {
        if(c>='0'&& c<='9')
        {
            c-='0';
            answer+=c;
        }
    }
    return answer;
}