-
Notifications
You must be signed in to change notification settings - Fork 7
/
Main.java
63 lines (55 loc) · 1006 Bytes
/
Main.java
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package basicLevel1002;
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String n = in.nextLine();
in.close();
int sum = 0;
for (int i = 0; i < n.length(); i++) {
sum += n.charAt(i) - '0';
}
Stack<String> stack = new Stack<>();
do {
int unit = sum % 10;
switch (unit) {
case 0:
stack.push("ling");
break;
case 1:
stack.push("yi");
break;
case 2:
stack.push("er");
break;
case 3:
stack.push("san");
break;
case 4:
stack.push("si");
break;
case 5:
stack.push("wu");
break;
case 6:
stack.push("liu");
break;
case 7:
stack.push("qi");
break;
case 8:
stack.push("ba");
break;
case 9:
stack.push("jiu");
break;
}
sum /= 10;
} while (sum != 0);
System.out.print(stack.pop());
while (!stack.isEmpty()) {
System.out.print(" " + stack.pop());
}
}
}