获取一个整数的每一位并存入数组
public class GetNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int count = 0;
for (int i=number; i!= 0; i/=10){
count++;
}
int[] arr = new int[count];
for (int i = 0; i < arr.length; i++) {
arr[i] = number % 10;
number = number / 10;
}
for (int i = 0, j = arr.length -1; i < j ; i++, j--) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
}