zoukankan      html  css  js  c++  java
  • 数字转大写(java)

    数字转大写

    public class bnum {
        public bnum() {
        }

       static String []bigNum={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
       static String []wei={"元","拾","佰","仟","万"};
       static String []swei={"角","分"};
       static String getNUM(String str){
          
        int t=Integer.parseInt(str);
        return bigNum[t];
        }
        static String getdanwei(int t){
        return wei[t];
        }

       
        public static void main(String[] args) {
            String strbig=new String("");
           
            float num=12345.78f;
            String temp=String.valueOf(num);
            int bi=temp.indexOf(".");
            int si=temp.length()-(bi+1);
            System.out.println(temp.length()+" "+bi+" "+si);
            int j=bi;
            for (int  i =0;  i<bi;i++) {
                strbig+=getNUM(temp.substring(i,i+1));
                strbig+=getdanwei(j-1);
                j--;
            }
            temp=temp.substring(bi+1,temp.length());
            for (int i = 0; i < si; i++) {
               
                strbig+=getNUM(temp.substring(i,i+1));
                strbig+=swei[i];
            }
           
            System.out.println(strbig);
        }
    }

  • 相关阅读:
    拉格朗日插值
    [数论] hdu 5974 A Simple Math Problem (数论gcd)
    混合图欧拉回路
    上下界网络流
    HDU 6623 Minimal Power of Prime(数学)
    图的连通度
    最小点权覆盖和最大点权独立集
    最大权闭合子图(最小割,蕴含式最大获利问题)
    CodeForces Goodbye 2017
    网络流建模汇总
  • 原文地址:https://www.cnblogs.com/ahuo/p/611534.html
Copyright © 2011-2022 走看看