![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include<stdio.h>
int func(__int64 x)
{
int h,a;
for(h=0;x>0;x=x/10)
{
a=x%10;
h+=a;
}
return h;
}
void main()
{
__int64 x;
while(1)
{
scanf("%I64d",&x);
printf("%d\n",(int)func(x));
}
}
#include<stdio.h>
int func(__int64 x)
{
int h,a;
for(h=0;x>0;x=x/10)
{
a=x%10;
h+=a;
}
return h;
}
void main()
{
__int64 x;
while(1)
{
scanf("%I64d",&x);
printf("%d\n",(int)func(x));
}
}
转载于:https://www.cnblogs.com/galczn/archive/2012/02/17/2355486.html