#include<stdio.h>
#include<math.h>
int main()
{
int n,i,k;
printf("enter the n\n");
scanf("%d",&n);
for(k=1;1;k++){
if(n/pow(10,k)==0){
break;
}else{
printf("%d\n",k);
}
}
printf("The number has %d words",k);
return 0;
}
你for循环的循环条件可能错了,计算位数其实可以用log10(n)+1