大写汉字转阿拉伯数字c语言,将输入的阿拉伯数字变换的汉字的大写输出

将输入的阿拉伯数字转换的汉字的大写输出

//题目:将输入的阿拉伯数字转换的汉字的大写输出

package test;

import java.io.*;

public class File_3

{

/**

* @param args

* n 临时存储商

*/

public void outNum(long number)

{

int i = 0;

int n = 0;

String str[] = {"十","百","千","万","十","百","千","亿"};

String num[] = {"零","一","二","三","四","五","六","七","八","九","十"};

int countLine = Long.toString(number).length();

String count[] = new String[countLine];

while(countLine >= 0)

{

n = (int)(number / Math.pow(10,countLine - 1)); //获取该位的数字

if(n != 0) //该位不为零时

{

if(countLine == 1) //如果到个位数时,只输出大写数字

{

count[i] = num[n];

}

else //否则数字后面加职称

{

count[i] = num[n] + str[countLine - 2];

number = number % (int)Math.pow(10,countLine - 1); //取余

}

i = i + 1;

countLine = countLine - 1;

System.out.print(num[n]);

System.out.print(str[countLine - 1]);

}

else //该位为零时

{

System.out.print(num[n]);

i = i + 1;

countLine = countLine - 1;

}

}

}

public static void main(String[] args)throws IOException

{

// TODO 自动生成方法存根

try

{

BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

System.out.print("请输入数字: ");

long number = Long.parseLong(bin.readLine());

File_3 f1 = new File_3();

System.out.print("转换大写为: ");

f1.outNum(number);

}

catch(ArrayIndexOutOfBoundsException e)

{

}

}

}

运行结果: 请输入数字: 123456789

转换大写为: 一亿二千三百四十五万六千七百八十九

请输入数字: 120365124

转换大写为: 一亿二千零三十六万五千一百二十四

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值