long reverse(long number)
{
long result=0;
while(number>=10)
{
result*=10;//后面还有数字左移一位
result+=number%10;/将当前的个位数加上
number/=10;//将个数数割掉
}
return result;
}
#include
#include
#include
int main()
{
int number=12345;
char p[8];
itoa(number,p,10);
number=atoi(strrev(p));
printf("%d",number);
return 0;
}
#include
int reverse(int number)
{
int i,j=0;
while(number)
{
i=number%10;
number/=10;
j=j*10+i;
}
return j;
}
int main()
{
printf("%d\n",reverse(1234));
return 0;
}