-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoundNumbers.java
More file actions
29 lines (28 loc) · 912 Bytes
/
Copy pathRoundNumbers.java
File metadata and controls
29 lines (28 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class RoundNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int n = sc.nextInt();
List<Integer> roundNumbers = new ArrayList<>();
int place = 0;
while (n > 0) {
int digit = n % 10;
if (digit != 0) {
int round = digit * (int)Math.pow(10, place);
roundNumbers.add(round);
}
n /= 10;
place++;
}
System.out.println(roundNumbers.size());
for (int num : roundNumbers) {
System.out.print(num + " ");
}
System.out.println();
}
}
}