设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","ni设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","nine"} ; String y[]={ten","eleven","twelve

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/07 15:25:11
设有3个数组内容如下:Stringx[]={"zero","one","two","three",four","five","six",seven","eight","ni设有3个数组内容如下:Str

设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","ni设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","nine"} ; String y[]={ten","eleven","twelve
设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","ni
设有3个数组内容如下:
String x[]={"zero","one","two","three",four","five","six",seven","eight","nine"} ;
String y[]={ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen" };
String z[]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety" };
用Java命令行输入一个小于100的整数,将其翻成英文表示.
例如:
输入32,输出:thirty two
输入14,输出:fourteen
输入8,输出:eight
反之,输入英文表示,输出相应的整数.
public class test1 {
public static void main(String []args){
System.out.println(CtoE (32));
System.out.println(CtoE (14));
System.out.println(CtoE (8));
}
public static String CtoE(int a){
String x[]={"zero","one","two","three","four","five","six","seven","eight","nine"} ;
String y[]={"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen" };
String z[]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety" };
if(a>=0&a=10&a=20&a

设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","ni设有3个数组内容如下:String x[]={"zero","one","two","three",four","five","six",seven","eight","nine"} ; String y[]={ten","eleven","twelve
public static void main(String[] args) {
System.out.println(CtoE("twenty two"));
System.out.println(CtoE("ten"));
System.out.println(CtoE("five"));
}
public static String CtoE(String a) {
String shiwei = "";
String gewei = "";
String intShiWei = "";
String intGeWei = "";
a=a.toLowerCase();//全都转换成小写字母
//a.trim()去掉字母前后空格
if(a.trim().indexOf(" ")>-1)
{
shiwei = a.substring(0,a.indexOf(" "));
gewei = a.substring(a.lastIndexOf(" "),a.length());
//十位
if("twenty".equals(shiwei.trim())){
intShiWei ="2";
}else if("thirty".equals(shiwei.trim())){
intShiWei ="3";
}else if("fourty".equals(shiwei.trim())){
intShiWei ="4";
}else if("fifty".equals(shiwei.trim())){
intShiWei ="5";
}else if("sixty".equals(shiwei.trim())){
intShiWei ="6";
}else if("seventy".equals(shiwei.trim())){
intShiWei ="7";
}else if("eighty".equals(shiwei.trim())){
intShiWei ="8";
}else if("ninety".equals(shiwei.trim())){
intShiWei ="9";
}
//个位
if("zero".equals(gewei.trim())){
intGeWei ="0";
}else if("one".equals(gewei.trim())){
intGeWei ="1";
}else if("two".equals(gewei.trim())){
intGeWei ="2";
}else if("three".equals(gewei.trim())){
intGeWei ="3";
}else if("four".equals(gewei.trim())){
intGeWei ="4";
}else if("five".equals(gewei.trim())){
intGeWei ="5";
}else if("six".equals(gewei.trim())){
intGeWei ="6";
}else if("seven".equals(gewei.trim())){
intGeWei ="7";
}else if("eight".equals(gewei.trim())){
intGeWei ="8";
}else if("nine".equals(gewei.trim())){
intGeWei ="9";
}
}else
{
if("zero".equals(a.trim())){
intGeWei ="0";
}else if("one".equals(a.trim())){
intGeWei ="1";
}else if("two".equals(a.trim())){
intGeWei ="2";
}else if("three".equals(a.trim())){
intGeWei ="3";
}else if("four".equals(a.trim())){
intGeWei ="4";
}else if("five".equals(a.trim())){
intGeWei ="5";
}else if("six".equals(a.trim())){
intGeWei ="6";
}else if("seven".equals(a.trim())){
intGeWei ="7";
}else if("eight".equals(a.trim())){
intGeWei ="8";
}else if("nine".equals(a.trim())){
intGeWei ="9";
}else if("ten".equals(a.trim())){
intGeWei ="10";
}else if("eleven".equals(a.trim())){
intGeWei ="11";
}else if("twelve".equals(a.trim())){
intGeWei ="12";
}else if("thirteen".equals(a.trim())){
intGeWei ="13";
}else if("fourteen".equals(a.trim())){
intGeWei ="14";
}else if("fifteen".equals(a.trim())){
intGeWei ="15";
}else if("sixteen".equals(a.trim())){
intGeWei ="16";
}else if("seventeen".equals(a.trim())){
intGeWei ="17";
}else if("eighteen".equals(a.trim())){
intGeWei ="18";
}else if("nineteen".equals(a.trim())){
intGeWei ="19";
}
}
return (intShiWei+intGeWei);
}
这是最笨的方法了,其他的我还不知道,这个方法就是数越大,if越多,可以实现大于100的数,如果你常用的话,可以把这个写成一个通用的工具类

设有3个数组内容如下:String x[]={zero,one,two,three,four,five,six,seven,eight,ni设有3个数组内容如下:String x[]={zero,one,two,three,four,five,six,seven,eight,nine} ; String y[]={ten,eleven,twelve 设有如下定义:double x[15] 则x数组元素下标为多少? ‘设有如下定义:intx[10];则x数组元素下标的下限为_____,上限为_____ C#类型关键字全集说明说明格式如下:(type 说明文字.ef:typ 实例(使用或创建例子))例如:string 字符串型.ef:string str = ;string[] 字符串数组.ef:string[] a = {1,2,3,};int 整型.ef:int a = 25;最好把C#.net的类型 用JAVA编写一个使用随机数创建句子使用3个字符串数组String[] article = {the,a,one}; String[] noun = {boy,dog,bird}; String[] verb = {jumped,ran,flew}; 用随机数分别从3个数组中抽取3个单词连成句子 设有定义int x[2][3];则关于二维数组x叙述错误是?可以用语句x[0]=0,为数组所有元素赋初值0 这句咋错了 C输入10个实数存于数组,阀值X输出所有大于阀值X的实数存于的数组的内容 一道C语言的题,设有定义 short x[5]={1,2,3}; 则数组占用的内存字节数是?知道的麻烦说的详细一点 pascal 只有一行共有n个元素:数组A的编码B描述 Description 设有一个数组A:array[0..n-1] of integer;数组中存放的元素为0至n-1之间的整数,且A[i]A[j](当ij时).如:n=6时,A=(4,3,0,5,1,2) 此时,数组A的编码定义 内容如下.X=4-X÷3求X 采用冒泡排序对如下数组排序String[] arr = { Now,is,the,time,for,all,good,men,to,come,to,the,aid,of,their,country}; 定义了StringBuffer数组,为什么还要创建string buffers如下程序:public class ThisHappens {public static void main(String[] args) {StringBuffer[] stringBuffers = new StringBuffer[10];for (int i = 0; i < stringBuffers.length; i ++) {strin c语言编程:设有一个数组,从键盘输入10个整数,要求找出最大的数和它的下标,并把它和数组中的第一个交换 设有如下数组定义:int a[3][4]={{1,3,5,7},{9,11,13,15},{17,19,21,23}}; 计算下面各项的值(设数组a的首地址为2000,一个int类型数占四个字节).(1)a[2][1] (2)a[1] (3)a (4)a+1 (5)*a+1( 设有如下定义:int x=10,y=3,z;则语句printf(%d ,z=(x%y,x/y));的输出结果是多少? 用C语言设计:从键盘上输入8个元素的值存入一堆数组a中,然后将下标为奇数(1,3,5,7.)的元素赋值给数组b,输出数组b的内容. 已知一个数组元素是数组的第几个元素,如何计算它是在数组中的第几行,第几列?例如:已知数组a如下(3 * 3):0 0 01 0 00 3 0所以可知a[3] = 1.假如现在已知1是数组a中的第3个元素,如何计算它是 设有4x4二维数组a[4][4]和b[4][4]如下:1 3 5 72 4 6 8a= 11 13 15 17 B = 10 12 14 1617 19 21 23 18 20 22 2425 27 29 31 26 28 30 321.实现C=A+B2.将A的第二行复制到一位数组AB中3.将B的第三列复制到一维数组BB中