언어공부/[BAEKJOON] C#
[ 프로그래머스 ] 숨어있는 숫자의 덧셈 (2)_Lv.0
zzerou
2023. 1. 25. 11:20
https://school.programmers.co.kr/learn/courses/30/lessons/120864
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
using System;
public class Solution {
public int solution(string my_string) {
int answer = 0;
int save = 0;
for(int i=0; i<my_string.Length; i++){
if(char.IsDigit(my_string[i]) == true)
{
save = save * 10 + ((int)my_string[i] - 48);
}
else
{
answer += save;
save = 0;
}
}
return answer;
}
}
https://learn.microsoft.com/ko-kr/dotnet/api/system.char.isdigit?view=net-7.0 -> Char.IsDigit