PAT (B) 题目1002

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String number = sc.nextLine();
		int length = number.length();
		int sum = 0;
		int count = 0;
		for(int i=0;i<length;i++) {
			int temp = Integer.parseInt(number.substring(i, i+1));//字符串转整型
			sum = sum + temp;//求和
		}
		int numberList[] = new int[100];
		do {
			numberList[count] = sum%10;
			sum = sum/10;
			count++;
		}while(sum!=0);//求和的每一位数字
		String engList[] = new String[count]; 
		for(int i=0;i<count;i++) {
			switch (numberList[i]) {
			case 0:
				engList[i] = "ling";
				break;
			case 1:
				engList[i] = "yi";
				break;
			case 2:
				engList[i] = "er";
				break;
			case 3:
				engList[i] = "san";
				break;
			case 4:
				engList[i] = "si";
				break;
			case 5:
				engList[i] = "wu";
				break;
			case 6:
				engList[i] = "liu";
				break;
			case 7:
				engList[i] = "qi";
				break;
			case 8:
				engList[i] = "ba";
				break;
			case 9:
				engList[i] = "jiu";
				break;		
			}
		}//数字转拼音
		for(int i=count-1;i>=0;i--) {
			if(i!=0) {
				System.out.print(engList[i]+" ");
			}else {
				System.out.print(engList[i]);//避免末尾出现空格  
			}
		}
		
	}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值