#include <iostream>
#include <math.h>
using namespace std;
bool is_num(char a) {
if (a == '0' || a == '1' || a == '2' || a == '3' || a == '4' || a == '5' || a == '6' || a == '7' || a == '8' || a == '9')
return true;
else
return false;
}
int main() {
long long temp = 0, result = 0;
int length, jump = 1;
cin >> length;
char* word = new char[length+1];
cin >> word;
for (int i = length; i >= 0; i--) {
if (is_num(word[i])) {
temp += (word[i] - '0') * jump;
jump *= 10;
}
if (i == 0 || !is_num(word[i])) {
result += temp;
temp = 0;
jump = 1;
}
}
cout << result;
return 0;
}
'컴퓨터 > 문제 풀기' 카테고리의 다른 글
c++ 생성자에는 초기값 대입만 쓰자 (0) | 2020.02.04 |
---|---|
백준 8741번 이진수 합 (0) | 2019.07.29 |
백준 4948번 베르트랑 공준 (0) | 2019.05.20 |
백준 1946번 신입 사원 (0) | 2019.05.20 |
백준 16955번 오목, 이길 수 있을까? (0) | 2019.05.20 |