#include<iostream>
using namespace std;
char exchange(int a);
int search1(int a)
{
///
int yi,qw,bw,sw,w,k=0,b=0,shi=0,ge=0;
int &s=shi;
char store[9];
ge=a%10;//个位
shi=(a%100-ge)/10;//十位
b=(a%1000-shi*10-ge)/100;//百位
k=(a%10000-b*100-shi*10-ge)/1000;//千位
w=(a%100000-k*1000-b*100-shi*10-ge)/10000;
sw=(a%1000000-w*10000-k*1000-b*100-shi*10-ge)/100000;//十万
bw=(a%10000000-sw*100000-w*10000-k*1000-b*100-shi*10-ge)/1000000;//百万
qw=(a%100000000-bw*1000000-sw*100000-w*10000-k*1000-b*100-shi*10-ge)/10000000;//千万
yi=(a-a%10000000)/100000000;//亿
if(yi!=0)
{
cout<<exchange(yi)<<"亿";}
if(qw==0)
{
if(bw==0)
{
if(sw==0)
{
if(w==0)
{}
else
{
cout<<exchange(w)<<"万";
}
}
else if(sw!=0)
{
if(w==0)
{
cout<<exchange(sw)<<"十万零";
}
else
{
cout<<exchange(sw)<<"拾";
cout<<exchange(w)<<"万";
}
}
}
else if(bw!=0)
{
if(sw==0)
{
if(w==0)
{cout<<exchange(bw)<<"百万零";}
else
{
cout<<exchange(bw)<<"百零";
cout<<exchange(w)<<"万";
}
}
else if(sw!=0)
{
if(w==0)
{
cout<<exchange(bw)<<"百";
cout<<exchange(sw)<<"十";
cout<<exchange(w)<<"万零";
}
else
{
cout<<exchange(bw)<<"百";
cout<<exchange(sw)<<"拾";
cout<<exchange(w)<<"万";
}
}
}
}
else if(qw!=0)
{
if(bw==0)
{
if(sw==0)
{
if(w==0)
{cout<<exchange(qw)<<"千万零";}
else
{
cout<<exchange(qw)<<"千零";
cout<<exchange(w)<<"万";
}
}
else if(sw!=0)
{
if(w==0)
{
cout<<exchange(qw)<<"千零";
cout<<exchange(sw)<<"十万零";
}
else
{
cout<<exchange(qw)<<"千零";
cout<<exchange(sw)<<"拾";
cout<<exchange(w)<<"万";
}
}
}
else if(bw!=0)
{
if(sw==0)
{
if(w==0)
{
cout<<exchange(qw)<<"千";
cout<<exchange(bw)<<"百万零";
}
else
{
cout<<exchange(qw)<<"千";
cout<<exchange(bw)<<"百零";
cout<<exchange(w)<<"万";
}
}
else if(sw!=0)
{
if(w==0)
{
cout<<exchange(qw)<<"千";
cout<<exchange(bw)<<"百";
cout<<exchange(sw)<<"十万零";
}
else
{
cout<<exchange(qw)<<"千";
cout<<exchange(bw)<<"百";
cout<<exchange(sw)<<"十";
cout<<exchange(w)<<"万";
}
}
}
}
if(w!=0 && k==0)
{
cout<<"零";
}
if(k==0)
{
if(b==0)
{
if(s==0)
{
if(ge==0)
{}
else
{
cout<<exchange(ge);
}
}
else if(s!=0)
{
if(ge==0)
{
cout<<exchange(s)<<"十零";
}
else
{
cout<<exchange(s)<<"拾";
cout<<exchange(ge);
}
}
}
else if(b!=0)
{
if(s==0)
{
if(ge==0)
{cout<<exchange(b)<<"百零";}
else
{
cout<<exchange(b)<<"百零";
cout<<exchange(ge);
}
}
else if(s!=0)
{
if(ge==0)
{
cout<<exchange(b)<<"百";
cout<<exchange(s)<<"十";
cout<<exchange(ge);
}
else
{
cout<<exchange(b)<<"百";
cout<<exchange(s)<<"拾";
cout<<exchange(ge);
}
}
}
}
else if(k!=0)
{
if(b==0)
{
if(s==0)
{
if(ge==0)
{cout<<exchange(k)<<"千零";}
else
{
cout<<exchange(k)<<"千零";
cout<<exchange(ge);
}
}
else if(s!=0)
{
if(ge==0)
{
cout<<exchange(k)<<"千零";
cout<<exchange(s)<<"十万零";
}
else
{
cout<<exchange(k)<<"千零";
cout<<exchange(s)<<"十";
cout<<exchange(ge);
}
}
}
else if(b!=0)
{
if(s==0)
{
if(ge==0)
{
cout<<exchange(k)<<"千";
cout<<exchange(b)<<"百零";
}
else
{
cout<<exchange(k)<<"千";
cout<<exchange(b)<<"百零";
cout<<exchange(ge);
}
}
else if(s!=0)
{
if(ge==0)
{
cout<<exchange(k)<<"千";
cout<<exchange(b)<<"百";
cout<<exchange(s)<<"十零";
}
else
{
cout<<exchange(k)<<"千";
cout<<exchange(b)<<"百";
cout<<exchange(s)<<"十";
cout<<exchange(ge);
}
}
}
}
}
char exchange(int a)
{
if(a==1)
cout<<" 壹";
else if(a==2)
cout<<" 贰";
else if(a==3)
cout<<" 叁";
else if(a==4)
cout<<" 肆";
else if(a==5)
cout<<" 伍";
else if(a==6)
cout<<" 陆";
else if(a==7)
cout<<" 柒";
else if(a==8)
cout<<" 八";
else if(a==9)
cout<<" 玖";
return ' ';
};
int main()
{
int a;
cout<<"请输入金额"<<endl;
cin>>a;
if(a>999999999)
cout<<"数据溢出,请输入十亿以内的数字"<<endl;
else if(a<999999999&&a>0)
{
cout<<"转换大写后的金额为"<<endl;
search1(a);
}
else if(a==0)
cout<<"零";
return 0;
}