-
문자열 속의 숫자의 합(재귀)코딩/C언어 2019. 9. 17. 11:50반응형123456789101112131415161718192021222324252627#include <stdio.h>#include <stdbool.h>#include <stdlib.h>int solution(char* s) {//int i;if (*s == NULL)return 0;else if (*s >= '0' && *s <= '9'){return *s - '0' + solution(++s);}else{s++;return solution(s);}}int main(void){char s[20];scanf("%s", s);printf("%s", solution(s));}
cs 결과:
반응형'코딩 > C언어' 카테고리의 다른 글
다음에 올 피보나치 수 구하기 (0) 2019.09.17 문자열 분해 (숫자, 문자) (0) 2019.09.17 Finding Palindrome (0) 2019.09.02 중복없는 수 저장 (0) 2019.09.02 문자열 중복문자 제거 (0) 2019.09.02