#include<stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d", &a);
b = DigitSum(a);
printf("%d\n", b);
system("pause");
return 0;
}
int DigitSum(int x)
{
int ret = 0;
if (x == 0)
{
return ret;
}
ret = x % 10;
x = x / 10;
return ret + DigitSum(x);
}
本文出自 “零点时光” 博客,请务必保留此出处http://10741764.blog.51cto.com/10731764/1711219