PS:不要复制网上找的,都错了。求高手回答。
程序运行输入123.45试试:
#include <stdio.h>#include <stdlib.h>
#include <wchar.h>
#include <locale.h>
wchar_t cstrs[10];
wchar_t bit[10];
int main()
{
cstrs[0]=0x96F6;cstrs[1]=0x58F9;cstrs[2]=0x8D30;
cstrs[3]=0x53C4;cstrs[4]=0x8086;cstrs[5]=0x4F0D;
cstrs[6]=0x9678;cstrs[7]=0x67D2;cstrs[8]=0x634C;
cstrs[9]=0x7396;
bit[0]=0x5706;bit[1]=0x62FE;bit[2]=0x4F70;
bit[3]=0x4EDF;bit[4]=0x842C;bit[5]=0x62FE;
bit[6]=0x4F70;bit[7]=0x4EDF;bit[8]=0x5104;
bit[9]=0x62FE;bit[10]=0x4F70;bit[11]=0x4EDF;
bit[12]=0x842C;
setlocale(LC_ALL, "");
double innum;
int k=0; int tmp=1;
scanf("%lf", &innum);
while(tmp<innum){
k+=1; tmp*=10;
}
if(tmp>innum){k--; tmp=tmp/10;}
if(k<0){k=0, tmp=1;}
int e, ee, t=0;
e=(int)innum;
while(e>=1){
ee = (int)e/tmp;
if(ee!=0){
if(t){
printf("%lc",cstrs[0]);
t=0;
}
printf("%lc", cstrs[ee]);
printf("%lc", bit[k]);
} else {
t=1;
if(k==8 || k==4)printf("%lc",bit[k]);
}
k--; e=e%tmp; tmp=tmp/10;
}
long et;
et=(long)(innum*10); printf("%lc%lc",cstrs[et%10], 0x89D2);
et=(long)(innum*100); printf("%lc%lc",cstrs[et%10], 0x5206);
puts("");
return 0;
}
/*
例如:
输入:
256000023.22
输出:
贰亿伍仟陆佰万零贰拾叄圆贰角贰分
*/追问
你这个我之前网上找了,能运行,但转换的是错的。
追答呵呵,能在网上找,还在这里问。
到现在我也没有找出一个完美转换的程序。
比如:
10000100.01
之类的。
温馨提示:答案为网友推荐,仅供参考
第1个回答 2013-06-07
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>
wchar_t cstrs[10];
wchar_t bit[10];
int main()
{
int e, ee, t=0;
long double innum;
int k=0; int tmp=1;
long et,em;
printf("**********************************************************\n");
printf("* *\n");
printf("* 数字金额转换为大写金额程序 Ver,1.0 *\n");
printf("* *\n");
printf("* By RZLIN *\n");
printf("* *\n");
printf("* 请输入要转换的金额: *\n");
printf("* ");
cstrs[0]=0x96F6;cstrs[1]=0x58F9;cstrs[2]=0x8D30;
cstrs[3]=0x53C4;cstrs[4]=0x8086;cstrs[5]=0x4F0D;
cstrs[6]=0x9678;cstrs[7]=0x67D2;cstrs[8]=0x634C;
cstrs[9]=0x7396;
bit[0]=0x5706;bit[1]=0x62FE;bit[2]=0x4F70;
bit[3]=0x4EDF;bit[4]=0x842C;bit[5]=0x62FE;
bit[6]=0x4F70;bit[7]=0x4EDF;bit[8]=0x5104;
bit[9]=0x62FE;bit[10]=0x4F70;bit[11]=0x4EDF;
bit[12]=0x842C;
setlocale(LC_ALL, "");
scanf("%lf", &innum);
printf("* 您输入的金额为:%2lf *\n",innum);
printf("* *\n");
printf("*转换为大写金额是:");
while(tmp<innum){
k+=1; tmp*=10;
}
if(tmp>innum){k--; tmp=tmp/10;}
if(k<0){k=0, tmp=1;}
e=(int)innum;
while(e>=1){
ee = (int)e/tmp;
if(ee!=0){
if(t){
printf("%lc",cstrs[0]);
t=0;
}
printf("%lc", cstrs[ee]);
printf("%lc", bit[k]);
} else {
t=1;
if(k==8 || k==4)printf("%lc",bit[k]);
}
k--; e=e%tmp; tmp=tmp/10;
}
et=(long)(innum*10); printf("%lc%lc",cstrs[et%10], 0x89D2);
em=(long)(innum*10); printf("%lc%lc正*\n",cstrs[em%10], 0x5206);
printf("* *\n");
printf("* 请按任意键退出... *\n");
printf("**********************************************************");
puts("");
return 0;
}
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>
wchar_t cstrs[10];
wchar_t bit[10];
int main()
{
int e, ee, t=0;
long double innum;
int k=0; int tmp=1;
long et,em;
printf("**********************************************************\n");
printf("* *\n");
printf("* 数字金额转换为大写金额程序 Ver,1.0 *\n");
printf("* *\n");
printf("* By RZLIN *\n");
printf("* *\n");
printf("* 请输入要转换的金额: *\n");
printf("* ");
cstrs[0]=0x96F6;cstrs[1]=0x58F9;cstrs[2]=0x8D30;
cstrs[3]=0x53C4;cstrs[4]=0x8086;cstrs[5]=0x4F0D;
cstrs[6]=0x9678;cstrs[7]=0x67D2;cstrs[8]=0x634C;
cstrs[9]=0x7396;
bit[0]=0x5706;bit[1]=0x62FE;bit[2]=0x4F70;
bit[3]=0x4EDF;bit[4]=0x842C;bit[5]=0x62FE;
bit[6]=0x4F70;bit[7]=0x4EDF;bit[8]=0x5104;
bit[9]=0x62FE;bit[10]=0x4F70;bit[11]=0x4EDF;
bit[12]=0x842C;
setlocale(LC_ALL, "");
scanf("%lf", &innum);
printf("* 您输入的金额为:%2lf *\n",innum);
printf("* *\n");
printf("*转换为大写金额是:");
while(tmp<innum){
k+=1; tmp*=10;
}
if(tmp>innum){k--; tmp=tmp/10;}
if(k<0){k=0, tmp=1;}
e=(int)innum;
while(e>=1){
ee = (int)e/tmp;
if(ee!=0){
if(t){
printf("%lc",cstrs[0]);
t=0;
}
printf("%lc", cstrs[ee]);
printf("%lc", bit[k]);
} else {
t=1;
if(k==8 || k==4)printf("%lc",bit[k]);
}
k--; e=e%tmp; tmp=tmp/10;
}
et=(long)(innum*10); printf("%lc%lc",cstrs[et%10], 0x89D2);
em=(long)(innum*10); printf("%lc%lc正*\n",cstrs[em%10], 0x5206);
printf("* *\n");
printf("* 请按任意键退出... *\n");
printf("**********************************************************");
puts("");
return 0;
}
第2个回答 2013-06-07
*\n"); printf("*转换为大写金额是:"); while(tmp<innum){ k =1; tmp*=10; } if(tmp>innum){k--; tmp=tmp/10;} if(k<0){k=0, tmp=1;} e=(int)innum; while(e>=1){ ee = (int)e/tmp; if(ee!=0){ if(t){ printf("%lc",cstrs[0]); t=0; } printf("%lc", cstrs[ee]); printf("%lc", bit[k]); } else { t=1; if(k==8 || k==4)printf("%lc",bit[k]); } k--; e=e%tmp; tmp=tmp/10; } et=(long)(innum*10); printf("%lc%lc",cstrs[et ], 0x89D2); em=(long)(innum*10); printf("%lc%lc正*\n",cstrs[em ], 0x5206); printf("* *\n"); printf("* 请按任意键退出... *\n"); printf("**********************************************************"); puts(""); return 0; }