CodeCollection2018
8/24/2019 - 6:50 AM

反转整数

public int reverseDigit(int num){
    if(num==0) return 0;
    int flag = num<0?-1:1;
    num = Math.abs(num);
    int res = 0 ;
    int temp = num;
    while(temp!=0){
        int cur = temp%10;
        res = res*10+cur;
        temp = temp/10;
    }
    return flag*res;
}