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))); } }
时间: 2024-10-14 21:37:14