用go或者java实现的数字转中文大写

联系方式:techinged@qq.com或者430353916@qq.com

用go或者java实现的数字转中文大写,支持的数字范围是-9999999999999999.99(超过负9000万亿)至9999999999999999.99(超过9000万亿)

代码下载地址:
https://download.csdn.net/download/techinged/86805082

截图如下:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 Java 实现数字换成中文大写的示例代码: ```java import java.util.Scanner; public class NumberToChinese { private static final String[] CN_NUMBERS = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"}; private static final String[] CN_UNITS = {"", "十", "百", "千", "万"}; public static String convert(int n) { if (n < 0) { return "负" + convert(-n); } if (n < 10) { return CN_NUMBERS[n]; } if (n < 100) { if (n % 10 == 0) { return CN_UNITS[1 + n / 10]; } else { return CN_UNITS[1 + n / 10] + CN_NUMBERS[n % 10]; } } if (n < 1000) { if (n % 100 == 0) { return CN_NUMBERS[n / 100] + "百"; } else if (n % 100 < 10) { return CN_NUMBERS[n / 100] + "百零" + convert(n % 100); } else { return CN_NUMBERS[n / 100] + "百" + convert(n % 100); } } if (n < 10000) { if (n % 1000 == 0) { return CN_NUMBERS[n / 1000] + "千"; } else if (n % 1000 < 100) { return CN_NUMBERS[n / 1000] + "千零" + convert(n % 1000); } else { return CN_NUMBERS[n / 1000] + "千" + convert(n % 1000); } } if (n < 100000000) { if (n % 10000 == 0) { return convert(n / 10000) + "万"; } else if (n % 10000 < 1000) { return convert(n / 10000) + "万零" + convert(n % 10000); } else { return convert(n / 10000) + "万" + convert(n % 10000); } } return ""; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.println(convert(n)); } } ``` 运行以上代码,输入一个整数,即可输出该整数的中文大写形式。例如,输入 123456789,输出结果为: ``` 一亿二千三百四十五万六千七百八十九 ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值