View Code
#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));
}
}

 

posted on 2012-02-17 11:20  C's  阅读(160)  评论(0编辑  收藏  举报