//输入一个数字 Scanner sc=new Scanner(System.in); int number=sc.nextInt(); //计算位数 int count=0; int j=number; while(j!=0){ j/=10; count++; } //放入到数组中 j=number; int[]arr=new int[count]; for (int i = count-1; i >=0; i--) { arr[i]=j%10; j/=10; }
将数字每个位数放入数组中
于 2024-03-02 16:00:09 首次发布