Reverse digits of an integer(数字倒换)
Reverse digits of an integer
Example1: x = 123, return 321
Example2: x = -123, return -321
把一个int型数字倒换,如上所示。
思路1:从原数中不断提取个位数a,且原数不断除以10(消去个位数:达到十进制右移的效果)
然后 迭代数=迭代数*10+个位数。最终的迭代数为结果。
原创
2015-11-08 21:29:22 ·
346 阅读 ·
0 评论