首页 > 代码库 > 网易2017 数字翻转

网易2017 数字翻转

package com.net163.question;

import org.junit.Test;

/**
 * Created by Administrator on 2016/11/11 0011.
 */
public class ReverseNumber {
    private int x = 123 , y=100;
    public int reverse(int num){
        String strX = new StringBuilder(String.valueOf(num)).reverse().toString();
        while(strX.toCharArray()[0]==‘0‘){
            strX = strX.replaceFirst("0","");
        }
        return Integer.valueOf(strX);
    }
    @Test
    public void testReverseNumber(){
        System.out.println(reverse(reverse(x)+reverse(y)));
    }
}

 

网易2017 数字翻转