• 回答数

    4

  • 浏览数

    207

夏初哥哥
首页 > 英语培训 > 数字输出英语

4个回答 默认排序
  • 默认排序
  • 按时间排序

qq小妹头

已采纳

//英文指的是英文单词吧,比如1输出one,2输出two,这貌似只能创建一个数字数组//我写了0到10的,0到999类似import java.util.Scanner;public class Convert { static final String WORDS_LIST[]={ "zero","one","two","three","four","five","six","seven","eight","nine","ten"}; public static void main(String []args) { Scanner scanner = new Scanner(System.in); int number; while(scanner.hasNextInt()){ number = scanner.nextInt(); if(number == -1){ System.out.println("exit"); scanner.close(); break; } if(number > WORDS_LIST.length){ System.out.println("Out of range error!"); continue; } String msg = String.format("The word of %1$s is:", number) + WORDS_LIST[number]; System.out.println(msg); } }}

数字输出英语

198 评论(8)

一首ciao情歌

为什么要用switch啊?如果你的意思是你的数字和英文是在asc码表中是对应的话根本不需要switch啊,系统直接会输出数字对应的英文啊。难道你的意思是你的每个英文是有编号的,输入编号后输出英文?这倒是要用switch 不过这个很简单啊比如scanf("%d",&a);switch(a){case 1:printf("first");break;case 2:printf("second");break;case 3:printf("third");break;default:printf("wrong");break;}一般形式就是这样的

137 评论(14)

都市月亮飘飘

是要将阿拉伯数字转成英文的表达吧?

265 评论(12)

最美遇见微风

这个你要知道数字与字母的对应,ASC表中可以找得到,然后输出时改变输出的类型,有整型变为字符型,如下面的程序:

#include

void main()

{

int a1,a2,a3,a4,a5;

printf("请输入a1,a2,a3,a4,a5的值:\n");

scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);

printf("输出的结果为:%c%c%c%c%c\n",a1,a2,a3,a4,a5);

}

运行结果如下:

357 评论(10)

相关问答