Code:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<stack>
using namespace std;
char zhuanhuan(char x)
{
if(x=='0')
x='a';
else if(x=='1')
x='b';
else if(x=='2')
x='c';
else if(x=='3')
x='d';
else if(x=='4')
x='e';
else if(x=='5')
x='f';
else if(x=='6')
x='g';
else if(x=='7')
x='h';
else if(x=='8')
x='i';
else if(x=='9')
x='j';
return x;
}
string zhuanhuann(int c)
{
string ss;
if(c==1)
ss="";
else if(c==2)
ss="S";
else if(c==3)
ss="B";
else if(c==4)
ss="Q";
else if(c==5)
ss="W";
else if(c==6)
ss="SW";
else if(c==7)
ss="BW";
else if(c==8)
ss="QW";
else if(c==9)
ss="Y";
return ss;
}
int main()
{
string s;
cin>>s;
if(s.size()==1)
{
char c=zhuanhuan(s[0]);
cout<<c<<endl;
return 0;
}
int len=s.size();
int x=s.rfind("0");
while(x==s.size()-1)
{
s.erase(x,1);
//printf("%d ",x);
x=s.rfind("0");
}
//cout<<endl;
for(int i=0; i<s.size(); i++)
{
char c=zhuanhuan(s[i]);
string cc=zhuanhuann(len-i);
if(cc=="SW")
{
int xx=i+1;
if(s[i+1]!='0'&&xx<s.size())
cc="S";
}
if(cc=="BW")
{
int xx=i+2;
if((s[i+1]!='0'||s[i+2]!='0')&&xx<s.size())
cc="B";
}
if(cc=="QW")
{
int xx=i+3;
if((s[i+1]!='0'||s[i+2]!='0'||s[i+3]!='0')&&xx<s.size())
cc="Q";
}
if(s[i]!='0')
{
cout<<c<<cc;
}
else if(i>0&&s[i-1]!='0')
{
cout<<c;
}
}
}
/*
1.个位数
2.除了第一位其他位都是0
3.105045008这种间断的数,对十万,百万,千万还是一百五十万这种数据类型的考察