此乃有问题的代码,有一个错误
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String num = sc.next();
int sum = 0;
int i = 0;
char[] one = num.toCharArray();
while (i != one.length) {
sum += one[i] - ‘0’;
i++;
}
int count = 1;
int c = sum;
while (c >= 10) {
c = c / 10;
count++;
}
int[] two = new int[10];
for (int j = 0; j <= count; j++) {
two[j] = sum % 10;
sum /= 10;
}
int k = 0;
while (two[k] != 0) {
k++;
}
int z=0;
for (z = k-1; z > 0; z–) {
out(two[z]);
System.out.print(" ");
}
out(two[z]);
}
public static void out(int s) {
switch (s) {
case 0:
System.out.print("ling");
break;
case 1:
System.out.print("yi");
break;
case 2:
System.out.print("er");
break;
case 3:
System.out.print("san");
break;
case 4:
System.out.print("si");
break;
case 5:
System.out.print("wu");
break;
case 6:
System.out.print("liu");
break;
case 7:
System.out.print("qi");
break;
case 8:
System.out.print("ba");
break;
case 9:
System.out.print("jiu");
break;
default:
break;
}
}
}