zoukankan      html  css  js  c++  java
  • 人名币转大写

     public static string get(string num)
            {
                //129
                string chNum = "零壹贰叁肆伍陆柒捌玖";//定义好大写的数字

                string zheng = "元拾佰仟万拾佰仟亿拾佰仟万";//定义好数位,从小到大排  


                string xiaoshu = "角分";//把整数和小数分开处理  
                string result = string.Empty;

                if (num.Contains("."))
                {
                    string[] temp = num.Split('.');
                    int index = temp[0].Length - 1;
                    for (int i = 0; i < temp[0].Length; i++)
                    {
                        result += chNum[Convert.ToInt32(temp[0][i].ToString())];
                        result += zheng[index];
                        index--;
                    }
                    for (int i = 0; i < temp[1].Length; i++)
                    {
                        //89
                        result += chNum[Convert.ToInt32(temp[1][i].ToString())];
                        result += xiaoshu[i];
                    }
                }
                else
                {
                    int index = num.Length - 1;
                    for (int i = 0; i < num.Length; i++)
                    {
                        result += chNum[Convert.ToInt32(num[i].ToString())];
                        result += zheng[index];
                        index--;
                    }
                }
                return result;
            }

    调用  string result = get("129.98");

  • 相关阅读:
    js 格式化时间
    js filter过滤数据
    vant 省市区三级联动 自定义json数据展示 取值
    移动端 table横向滚动
    js 判断字符串中是否包含某个字符串
    element ui form表单 刚进页面就验证
    js ES6 Promise.all 等两个接口都返回成功执行
    SDNU 1139.Emergency(起点更改最短路问题)
    SDNU 1062.Fibonacci(矩阵快速幂)
    SDNU 1103.买彩票(水题)
  • 原文地址:https://www.cnblogs.com/nsky/p/6775592.html
Copyright © 2011-2022 走看看