publicclassMain{ publicstaticvoidmain(String[] args){ String[] str = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; Scanner sc = new Scanner(System.in); String s = sc.nextLine(); int sum = 0; for(char c : s.toCharArray()){ sum += c-'0'; } //开始读sum的值,进行输出,注意后面没有空格 Stack<String> stack = new Stack<>(); while(sum!=0){ int n = sum %10; sum = sum/10; stack.push(str[n]); } while(!stack.isEmpty()){ System.out.print(stack.pop()); if(!stack.isEmpty()){ System.out.print(" "); } } } }