# SDNUOJ 1213.金额的中文大写

## 1213.金额的中文大写

Time Limit: 1000 MS    Memory Limit: 131072 KB
Total Submission(s): 9    Accepted Submission(s): 4

### Description

123.45转化为“壹佰贰拾叁元肆角伍分”。

1）当金额为整数时，只表示整数部分，省略小数部分，并添加“整”字。
例如：123表示为“壹佰贰拾叁元整”

2）当金额中有连续的0时（含一个0），只需写一个“零”即可。
例如：10005表示为“壹万零伍元整”

3）10元缩写为“拾元整”。

单位“元角分”

### Sample Input

123.45
123
10005
10

### Sample Output

壹佰贰拾叁元肆角伍分

## 题意非常清晰，就是说把阿拉伯数字的金额转换为中华民族的传统计量形式，真是一个弘扬传统文化的好题啊！做完这个题以后我对古代计量单位更了解了~~

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char ChinaNum[12][5]= {"","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char ChinaMon[20][5]={"元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰","仟","亿"};
char str[105];
void ChinMonCapConvert(long double x)
{
int i, j;
int mon[105];
int a = (int)x;
int b = (x-a+0.005)*100;
int c = a;
int len = 0;
for(i=0; c!=0; i++){
mon[i]=c%10;
c /= 10;
len++;
}
int flag = 0;
if(len==2) cout<<"拾"<<ChinaNum[a%10]<<"元";
else{
for(i=len-1; i>=0; i--)
{
if(flag&&mon[i]==0) continue;
else flag = 0;
if(mon[i]==0&&i>0){
flag = 1;
cout<<"零";
}
else cout<<ChinaNum[mon[i]]<<ChinaMon[i];
}
}
if(b==0) cout<<"整"<<endl;
else{
int p = b%10;
cout<<ChinaNum[b/10]<<"角";
if(p) cout<<ChinaNum[p]<<"分";
cout<<endl;

}
}
int main()
{
long double mon;
int a, b;
while(cin>>mon)
{
ChinMonCapConvert(mon);

}
return 0;
}