比我写的好多了。
void main(){
int n,i=0,sum=0;
scanf("%d",&n);
if (n==0) i=1;
while (n!=0){
sum+=n%10;
n/=10;
i++;
}
printf("num of digits is%d,sum of digits is%d\n",i,sum);
}
void main(){
int n,i=0,sum=0;
scanf("%d",&n);
if (n==0) i=1;
while (n!=0){
sum+=n%10;
n/=10;
i++;
}
printf("num of digits is%d,sum of digits is%d\n",i,sum);
}