这个题我写的过于麻烦了有点,建议大家还是看看别人的题解叭(暴风哭泣)。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int n = sc.nextInt();
int wei1 = 1;
int wei2 = 1;
int[] arr = new int[100];
int index = 0;
while (true){
wei1 = wei1 * 10;
if(n / wei2 == 0) break;
else {
arr[index] = n % wei1 / wei2;
wei2 = wei2 *10;
index++;
}
}
int cnt = 0;
for (int j = 0; j < index; j++) {
if(arr[j] != 0) cnt++;
}
System.out.println(cnt);
int as = 1;
int flat = 0;
for (int j = 0; j < index; j++) {
if(arr[j] != 0 && j == 0){
flat = 1;
System.out.print(arr[j]);
}else if(arr[j] != 0) {
if(flat == 0) System.out.print(arr[j]*as + " ");
else System.out.print(" " + arr[j]*as);
}
as = as * 10;
}
System.out.println();
}
}
}
}