用字符串很简单。
刚刚稍改了一下,如下应该能满足你要求:
public class T {
public static int test(int i){
int d=(int) ((i%10)*Math.pow(10,(i+"").length()-1));
if(i/10!=0){
d=d+test(i/10);
}
return d;
}
public static void main(String[]args){
System.out.println(test(1234));
}
}
追问这方法 挺好的, 可是 .....