首页 > 编程知识 正文

浙大翁恺c语言,翁恺c语言

时间:2023-05-06 13:01:27 阅读:185396 作者:3382

题目内容:
你的程序要读入一个整数,范围是[-100000,100000]。然后,用汉语拼音将这个整数的每一位输出出来。
如输入1234,则输出:
yi er san si
注意,每个字的拼音之间有一个空格,但是最后的字后面没有空格。当遇到负数时,在输出的开头加上“fu”,如-2341输出为:
fu er san si yi

输入格式:
一个整数,范围是[-100000,100000]。

输出格式:
表示这个整数的每一位数字的汉语拼音,每一位数字的拼音之间以空格分隔,末尾没有空格。

输入样例:
-30

输出样例:
fu san ling

时间限制:1000ms内存限制:64000kb

import java.util.Scanner;public class dushu {public static void main(String[] args) {// TODO Auto-generated method stubScanner in = new Scanner(System.in);int number;int count=0;int num = 1;number=in.nextInt();if(number>=-100000&&number<=100000){if(number<0){System.out.print("fu ");number=-number;}for(int shu=number;num!=0;){count=count+1;num=shu/10;shu=num;}for(int i=count;i>0;i--){int k=1;int shuzi;for(int j=1;j<i;j++){k=k*10;}shuzi=number/k;number=number%k;switch (shuzi) {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;}if(i>1){System.out.print(" ");}}}else{System.out.println("输入的整数范围是[-100000,100000]");}}}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。