#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; }
本文出自 “Vs吕小布” 博客,谢绝转载!
原文地址:http://survive.blog.51cto.com/10728490/1710677