c++ 数字转汉字

发布时间:2022-08-18 18:22


string zi(int i,int bit)
{
    string ret;
    if (0==i)
        ret = "零";
    else if(1 == i)
        ret = "一";
    else if(2 == i)
        ret = "二";
    else if(3 == i)
        ret = "三";
    else if(4 == i)
        ret = "四";
    else if(5 == i)
        ret = "五";
    else if(6 == i)
        ret = "六";
    else if(7 == i)
        ret = "七";
    else if(8 == i)
        ret = "八";
    else if(9 == i)
        ret = "九";
    if(ret == "零")
        return ret;
    if(1==bit)
       ret += "十";
    else if(2==bit)
        ret += "百";
    else if(3==bit)
        ret += "千";
    else if(4==bit)
        ret += "万";
    else if(5==bit)
        ret += "十";
    else if(6==bit)
        ret += "百";
    else if(7==bit)
        ret += "千";
    else if(8==bit)
        ret += "亿";
    else if(9==bit)
        ret += "十";
    else if(10==bit)
        ret += "百";
    else if(11==bit)
        ret += "千";
    else if(12==bit)
        ret += "万";
    else if(13==bit)
        ret += "十";
    else if(14==bit)
        ret += "百";
    else if(15==bit)
        ret += "千";
    else if(16==bit)
        ret += "亿";
    else if(bit > 16)
        return "你妹的,数字太大了";

    return ret;

}
string hanzi(unsigned long long ui)
{
    char si[50] = {0};
    _ui64toa_s(ui,si,50,10);
    int ilen = strlen(si);
    vector ret;
    for(int i=0; i=0; --i)
    {
            if(ret[i]=="零")
                ret.erase(ret.begin()+i);
            else
                break;
    }
    for(size_t i = 0;i

ItVuer - 免责声明 - 关于我们 - 联系我们

本网站信息来源于互联网,如有侵权请联系:561261067@qq.com

桂ICP备16001015号