1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main{ 5 public static void main(String[] args) { 6 Scanner input = new Scanner(System.in); 7 String temp = input.next(); 8 int[] a = new int[temp.length()]; 9 for(int i=0;i<temp.length();i++){ 10 a[i] = temp.charAt(i)-‘0‘; 11 } 12 String[] b = new String[10]; 13 b[0] = "ling"; 14 b[1] = "yi"; 15 b[2] = "er"; 16 b[3] = "san"; 17 b[4] = "si"; 18 b[5] = "wu"; 19 b[6] = "liu"; 20 b[7] = "qi"; 21 b[8] = "ba"; 22 b[9] = "jiu"; 23 String[] c = new String[10]; 24 c[0] = ""; 25 c[1] = "shi"; 26 c[2] = "bai"; 27 c[3] = "qian"; 28 c[4] = "wan"; 29 c[5] = "shi"; 30 c[6] = "bai"; 31 c[7] = "qian"; 32 c[8] = "yi"; 33 c[9] = "shi"; 34 for(int i=0;i<temp.length();i++){ 35 int j = temp.length()-i-1; 36 if(a[i]==0){ 37 if(j==0||j==4||j==8){ 38 System.out.print(c[j]+" "); 39 } 40 else if(a[i+1]!=0){ 41 System.out.print(b[a[i]]+" "); 42 } 43 44 }else if((j==1||j==5||j==9)&&a[i]==1){ 45 System.out.print(c[j]+" "); 46 }else{ 47 System.out.print(b[a[i]]+" "+c[j]+" "); 48 } 49 50 } 51 52 53 } 54 55 }
原文:http://www.cnblogs.com/lolybj/p/6501103.html