number=number%10;
number除以10取余,number已经变化了,因此最后得不到正确结果。
修改:
#include
int main()
{
int count,number,number1,sum;//增加定义变量number1
count=0; sum=0;
scanf("%d",&number);
do
{
number1=number%10;//将number改为number1,并将位置调整到此处
number=number/10;
count++;
sum=sum*10+number1; //将number改为number1
}
while(number!=0);
printf("%d\n%d",count,sum);
return 0;
}