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");

  • 相关阅读:
    怎样用 koa-router 实现 get 请求
    怎样用 koa-bodyparser 获取 POST 请求上下文中的表单数据
    怎样用 Koa 搭配 fs 模块返回一个 html 文件给前端
    怎样用 koa 解析出 POST 请求上下文中的表单数据
    怎样用 Koa 写 Hello, World!
    怎样使用 Vue-CLI 创建 Vue3 项目
    Koa 中怎样获取请求中的 query 参数
    怎样开发一个最简版 Koa 日志打印中间件
    怎样安装 Koa
    辅助理解 this 的一些代码片段
  • 原文地址:https://www.cnblogs.com/nsky/p/6775592.html
Copyright © 2011-2022 走看看