#include<stdio.h>
void main()
{
double x,y;
char *ch[]={"零","壹","貳","三","肆","伍","陸","柒","捌","玖"};
char *ch1[]={"拾","佰","仟","萬","拾","佰","仟","億"};
char num[256];
long i,n,j,m,y1;
printf("input:");
scanf("%lf",&x);
n=(long)x;/*得整數部分*/
y=x-n;/*得小數部分*/
for(i=0;n!=0;i++)
{
num[i]=(char)(n%10);
n/=10;
}
m=i;
num[i]='.';
for(y=y*10;(long)((y-(long)y)*10);) /*如果小數位還是有數(非0)循環繼續*/
y*=10;/*小數轉化為整數如0.11111轉為11111.00...*/
y1=(long)y;
for(i=m+1;y1!=0;i++)
{num[i]=(char)(y1%10);
y1=y1/10;}/*取各位上的數字*/
for(n=0;;n++)
{
if(num[n]=='.')
{
for(j=n-1;j>=0;j--)/*判斷是否是萬位,億位..如是再判斷是否是0如是就不輸出零.*/
{
if(m<=5)
if(m==5&&(int)num[j]==0)
;
else
printf("%s",ch[(int)num[j]]);/*輸出大寫壹..*/
else
if(m%4==0&&(int)num[j]==0)
;
else
printf("%s",ch[(int)num[j]]);
if(m>=2)
{printf("%s",ch1[m-2]);/*輸出拾佰仟..如有2位就輸出拾*/
m=m--;}
}
printf("點");
break;
}
}
for(i=i-1;num[i]!='.';i--)
printf("%s",ch[(int)num[i]]);/*輸出小數部分*/
}