L1-007. 念数字
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
翁恺
输入一个整数,输出每个数字对应的拼音。当整数为负数时,先输出“fu”字。十个数字对应的拼音如下:
0: ling 1: yi 2: er 3: san 4: si 5: wu 6: liu 7: qi 8: ba 9: jiu
输入格式:
输入在一行中给出一个整数,如: 1234
。
提示:整数包括负数、零和正数。
输出格式:
在一行中输出这个整数对应的拼音,每个数字的拼音之间用空格分开,行末没有最后的空格。如 yi er san si
。
-600输出样例:
fu liu ling ling
提交代码
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 a=sc.next();
for (int i = 0; i < a.length(); i++) {
if (i < a.length() - 1) {
switch (a.charAt(i)) {
case '-':
System.out.print("fu" + " ");
break;
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;
}
} else {
switch (a.charAt(i)) {
case '-':
System.out.print("fu");
break;
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;
}
}
}
}
}