其中 1000的结果应为 1!
1. 采用常规方式,如123->321 其过程为((3)*10+2)*10+1
private int reve(int x) {
// TODO Auto-generated method stub
int result = 0 ;
int temp = x;
while(temp > 0){
result = result * 10 + temp % 10;
temp /= 10;
}
return result;
}
private int reve(String x){
char[] chs = x.toCharArray();
int begin = 0;
int end = chs.length - 1;
while(begin < end){
if(chs[begin] != chs[end]){
char temp = chs[begin];
chs[begin] = chs[end];
chs[end] = temp;
}
++begin;
--end;
}
int result = Integer.parseInt(new String(chs));
return result;
}