---
title: "金额转换算法[转自csdn]"
author: "jackini"
date: "2007-01-22T22:33:14Z"
tags: []
slug: "csdn"
draft: false
lastmod: "2007-01-22T22:33:14Z"
id: 49294
url: "https://jackini.iteye.com/blog/49294"
---

java 代码

01. static String t1 = "零壹贰叁肆伍陆柒捌玖";
02. static char\[] n = { '仟', ' ', '拾', '佰' };
03. static char\[] n1 = {'萬','亿'};
04. static char end = '圆';
05. public static void print(String value, int pos, boolean b) {
06. if (pos == 0) {
07. System.out.print(end);
08. return;
09. }
10. String value2 = value.substring(1, value.length());
11. int printPos = value.charAt(0) - '0';
12. if (printPos != 0) {
13. if (b == true)
14. System.out.print(t1.charAt(0));
15. System.out.print(t1.charAt(printPos));
16. System.out.print(printPos == 0 ? "" : (n\[pos % 4] == ' ' ? "": n\[pos % 4]));
17. }
18. if (pos % 4 == 1 && pos &gt; 1) {
19. System.out.print(n1\[(pos / 4) - 1]);
20. print(value2, pos - 1,  false);
21. return;
22. }
23. print(value2, pos - 1, printPos == 0 ? true : false);
24. }

使用方法  
print("10010202070", 11, false);