题解 | #反转数字#
反转数字
http://www.nowcoder.com/practice/1a3de8b83d12437aa05694b90e02f47a
import java.util.*; public class Solution { /** * * @param x int整型 * @return int整型 */ public int reverse (int x) { // write code here long res = 0; while (x != 0) { res *= 10; res += x %10; x /= 10; } return res > Math.pow(2, 31) - 1 || res < -Math.pow(2, 31) ? 0 : (int) res; } }