我的程序:
#include<stdio.h>
#include<math.h> int main(){
int n,a,b,s=,t;
scanf("%d",&n);
a = (int)log10(n) + ;
b = a;
while(b>){
b--;
t = pow(,b);
s += n/t;
n = n%t;
}
s += n;
printf("%d %d",a,s);
}
网友的程序,更简洁:
#include <stdio.h>
int main(){
int n, count, sum;
sum = ;
count = ;
scanf("%d", &n);
while(n!=){
count++;
sum += n%;
n /= ;
}
printf("%d %d\n", count, sum); return ;
}