zoukankan      html  css  js  c++  java
  • 阿拉伯数字转化为中文(缩写)数值

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

    #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;
    
    }
  • 相关阅读:
    053-157
    053-496
    053-128
    053-167
    053-250
    053-674
    离职申请
    日记


  • 原文地址:https://www.cnblogs.com/qiuhaifeng/p/11494382.html
Copyright © 2011-2022 走看看