题目内容:你的程序要读入一个整数,范围是[-100000,100000]。然后,用汉语拼音将这个整数的每一位输出出来。如输入1234,则输出:yi er san si
注意,每个字的拼音之间有一个空格,但是最后的字后面没有空格。当遇到负数时,在输出的开头加上“fu”,如-2341输出为:fu er san si yi
输入格式:一个整数,范围是[-100000,100000]。
输出格式:表示这个整数的每一位数字的汉语拼音,每一位数字的拼音之间以空格分隔,末尾没有空格。
输入样例:-30 输出样例:fu san ling
时间限制:500ms内存限制:32000kb
import java.util.Scanner;
public class Main {
public static void Check(int n,String[] str,int count){
switch (n) {
case 0:
str[count] = "ling";
break;
case 1:
str[count] = "yi";
break;
case 2:
str[count] = "er";
break;
case 3:
str[count] = "san";
break;
case 4:
str[count] = "si";
break;
case 5:
str[count] = "wu";
break;
case 6:
str[count] = "liu";
break;
case 7:
str[count] = "qi";
break;
case 8:
str[count] = "ba";
break;
case 9:
str[count] = "jiu";
break;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num1 = in.nextInt();
String[] str = new String[6];
int count = 0;
if ( num1 < 0 ){
System.out.print("fu ");
num1 = -num1;
}
do {
int x = num1%10;
Check(x,str,count);
count++;
num1 = num1/10;
}while(num1>0);
for (int i = count-1;i >= 0;i--) {
System.out.print(str[i]);
if (i != 0) {
System.out.print(" ");
}
}
}
}