标签:c
#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
输入一个数,最终将该数各个位数之和输出:for example: 1927 最终输出19
标签:c
原文地址:http://10741764.blog.51cto.com/10731764/1711219