PAT乙级1002

此乃有问题的代码,有一个错误

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;

	}

}

}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值