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

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

Posted by t9thkid at 2006-12-15 21:45:37 on Problem 1504
In Reply To:这道题根本就是输入两个Int的整数....不用开大数组嘛 Posted by:humanjustic at 2006-12-09 11:17:34
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