2018/12/04 PAT刷题 L1-007 念数字 java
代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str=sc.next(); sc.close(); int len = str.length(); String str1[] = new String[len]; String nian[] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "qiu"}; for(int i=0; i<len; i++) { str1[i]=str.charAt(i)+""; if(str1[i].equals("-")) { System.out.print("fu"); } else { System.out.print(nian[Integer.parseInt(str1[i])]); } if (i>=0 && i<len-1) { System.out.print(" "); } } } }