//对一个number进行倒置
public class NumberInversion2
{
public static void main(String[] args)
{
int num = 123456;
int numbk = 0;
int plus = 100000;
for(int i=0; i < 6; i++){
numbk += plus*(num%10);
plus = plus/10;
num = num/10;
}
System.out.println(numbk);
}
}
另附网友的另一种算法
public class NumberC {
public static void main(String[] args) {
int num = 123456;
char[] numx = String.valueOf(num).toCharArray();
for(int i=0; i<numx.length/2; i++) {
if(i != numx.length-1-i) {
char temp = numx[i];
numx[i] = numx[numx.length-1-i];
numx[numx.length-1-i] = temp;
}
}
for (char str : numx) {
System.out.println(str);
}
}
}