본문 바로가기
C++

[프로그래머스] 숨어있는 숫자의 덧셈 (1)

by 띰쥬 2025. 9. 5.
728x90
반응형
SMALL

#include <string>
#include <vector>

using namespace std;

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

728x90
반응형
LIST

댓글