首页 > 其他 > 详细

阿拉伯数字转化为中文(缩写)数值

时间:2019-09-09 22:32:12      阅读:106      评论:0      收藏:0      [点我收藏+]

阿拉伯数字转化为中文(缩写)数值:

#include<iostream>
#include<algorithm>
#include<vector>
#include<sstream>
using namespace std;

string tostring(int a){
    stringstream ss;
    ss<<a;
    string res;
    ss>>res;
    return res;
}
int main(){
    int a;
    cin>>a;
    string res;
    vector<char>arr{'S','B','Q','W'};
    int pos=0;
    while(a!=0){
        if(pos==5){
            pos=1;
        }
        if(pos==0){
            if(a%10){
                res.push_back(char(a%10+'0'));
            }
        pos=pos+1;
        }
        else{
            if(a%10){
                res.push_back(arr[pos-1]);
                res.push_back(char(a%10+'0'));
            }
            pos=pos+1;
        }
        a=a/10;
    }
    reverse(res.begin(),res.end());
    cout<<res;
    return 0;

}

阿拉伯数字转化为中文(缩写)数值

原文:https://www.cnblogs.com/qiuhaifeng/p/11494382.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!