| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
根本就不需要开数组,贴一个直接逆转整数的codeIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator