Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:根本就不需要开数组,贴一个直接逆转整数的code

Posted by try_and_try at 2007-07-20 02:31:35 on Problem 1504
In Reply To:根本就不需要开数组,贴一个直接逆转整数的code Posted by:t9thkid at 2006-12-15 21:45:37
> int reverse(int num)
> {
>     int res, tmp, len, add, i;
>     tmp=num;
>     len=0;
>     while(tmp>0)
>     {
>         tmp/=10;
>         len++;
>     }
>     tmp=num;
>     res=0;
>     for(i=1; i<=len; i++)
>     {
>         add=tmp%10;
>         res+=add*pow(len-i);  //int pow(int n)  for 10^n
>         tmp/=10;
>     }
>     return res;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator