如 输入 123 输出321.同时计算位数。
#include<stdio.h>
int main()
{
int reserve=0,count=0,n,n1;
scanf("%d",&n);
while(n!=0)
{
n1=n%10;//求个位
reserve=reserve*10+n1;//求倒序的数
n=n/10;//让输入的数减少一位,减少的是个位,原理是数的取整,因为类型是int。
count++;//求位数。
}
printf("位数=%d 倒序的结果=%d\n",count,reserve);
return 0;
}