#include<stdio.h>
#include<stdlib.h>
int sumfun(int num)
{
int m = 0;
int sum = 0;
if (num!=0)
{
m = num % 10;
num = num / 10;
sum=sumfun(num)+m;
}
return sum;
}
int main()
{
int num = 1729;
int ret = sumfun(num);
printf("%d\n", ret);
system("pause");
return 0;
}
转载于:https://blog.51cto.com/10740329/1714869