#include "ibe.h"
int tobig(char *m, char * out)
{
char *q,k[1024],d[1024],dw[1024],ch;
int j,i;
bufclr(d);
bufclr(k);
bufclr(dw);
q=k;
i=(strlen(m)-1)*2;
strcpy(d,"零壹贰叁肆伍陆柒捌玖");
strcpy(dw,"分角元拾佰仟万拾佰仟亿");
for (j=1;j<=strlen(m);j++)
{
ch=m[j-1];
memcpy(q,&d[atoi(&ch)*2],2);
q=q+2;
memcpy(q,&dw[i],2);
i=i-2;
q=q+2;
}
strcpy(out,k);
}
main()
{
char rp[1024];
bufclr(rp);
tobig("1234560100",rp);
printf("%s",rp);
}
vprofessor 回复于:2004-07-14 21:29:26 |
这个程序写的很简练,但是转换后的大写金额不规范啊,有时也不正确。如30.00。转换后为:叁佰零拾零元零角零分 |
htldm 回复于:2004-07-15 07:17:43 |
#include<stdio.h>
char str[64] = "币"; char tbl0[] = "零壹贰叁肆伍陆柒捌玖"; char tbl1[] = "万仟佰拾亿仟佰拾万仟佰拾元 角分整"; char* UPMONEY( double mony ) { char buf[17]; int i, j, c, p; sprintf(buf, "%16.2lf", mony); printf( "%s \n", buf ); p = 2; j = 0; for( i = 0; i < 16; i++) { switch( c = buf[i] ) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if( j != 0 ) { str[p++] = tbl0[0]; /* 零 */ str[p++] = tbl0[1]; } c = 2 * (c - '0'); str[p++] = tbl0[c++]; /* 数 */ str[p++] = tbl0[c++]; str[p++] = tbl1[2*i]; /* 数的位 */ str[p++] = tbl1[2*i+1]; j = 0; break; case '0': j++; if( ((j<4) && ((i == 4) || ( i == 8 ))) || ( i == 12 ) ) { str[p++] = tbl1[2*i]; /* 亿 万 元 */ str[p++] = tbl1[2*i+1]; } break; case ' ': break; case '.': break; }; } if( (j>=2 ) && ( i == 16 ) ) { str[p++] = tbl1[2*i]; /* 整 */ str[p++] = tbl1[2*i+1]; } str[p] = '\0'; return(str); } main() { double l; char str[64]; printf("please insert a number:"); scanf("%lf",&l); sprintf(str,"%s",UPMONEY(l)); printf("the number is %s",str); } |
ecloud 回复于:2004-07-16 13:03:22 |
我以前有个python写的,算是比较完善的,发在www.linuxforum.net的Python版面,现在公司网络有点问题登不上,你们可以去看看,我都忘得差不多了 |
hongqi 回复于:2004-07-16 21:59:38 |
不错 |
sqbcai 回复于:2004-07-25 22:32:39 |
不知有无shell写的此类程序? |
sdccf 回复于:2004-07-25 23:06:44 |
有shell写的,搜索一下. |
feiyan98 回复于:2004-11-11 20:51:25 |
在个位不为0的整数转换时,没有‘整’字。
比如89.00转换后是‘币八十九元’,没有整。 请问该怎样修改?谢谢! |
纳兰婷 回复于:2004-11-11 20:53:12 |
谢谢~~~收藏 |
wayy2008 回复于:2005-03-22 19:52:15 |
[quote:ffa66ec6cd="sqbcai"]不知有无shell写的此类程序?[/quote:ffa66ec6cd]
有,需要的话跟我联系,等我有空传上来看一下也可以. |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/