#include<stdio.h> int DigitSum(unsigned int n) { int num = 0; if( n == 0) { return num; } else num = n%10; n /= 10; return num + DigitSum(n); } int main() { unsigned int n = 0; int ret = 0; printf("請輸入一個非負整數:"); scanf("%d",&n); ret = DigitSum(n); printf("%d\n",ret); return 0; }