#include "stdio.h"
int main()
{
int a,sum;
while(scanf("%d",&a)&&a)
{
sum=0;
while(a)
{
sum+=a%10;
a/=10;
}
printf("%d\n",sum);
}
return 0;
}
楼上写的不对
还有问题可以继续提问
int sum(int n)
{
int s=0;
while (n>0)
{
s = s % 10;
n = n / 10;
}
return s;
}