import java.util.ArrayList;
import java.util.List;
public class DirectMemoryOOM {
private static String hanDigiStr[] = new String[] { "零", "壹", "贰", "叁", "肆", "伍",
"陆", "柒", "捌", "玖" };
private static String hanDiviStr[] = new String[] { "", "拾", "佰", "仟", "万", "拾",
"佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰",
"仟", "万", "拾", "佰", "仟" };
public static void main(String[] args) throws Exception {
int val = 20405;
handlerValue(val);
}
private static void handlerValue(int val) {
List<Integer> list = new ArrayList<>();
while(val!=0){
list.add(val%10);
val/=10;
}
String res = "";
int j;
for (int i = list.size()-1; i >=0 ; i--) {
Integer num = list.get(i);
if(num!=0){
res+= hanDigiStr[num]+hanDiviStr[i];
}else{
j=i;
while(j>=0){
if(list.get(j)==num){
j--;
continue;
}
break;
}
if(j==-1) break;
res+=hanDigiStr[num];
i=j+1;
}
}
System.out.println(res);
}
}
将金额转成大写金额
最新推荐文章于 2024-11-17 12:24:42 发布