如何把:会计上的金额:123456789.321转换成中文大写 和 英文.??

yuansuibo108 2003-05-06 06:02:37
如何把:会计上的金额:123456789.321转换成中文大写 和 英文.??
壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖圆叁角贰分壹厘.
和相应的英文写法???????????
...全文
1453 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuansuibo108 2003-05-08
  • 打赏
  • 举报
回复
meCAD(狂学C++中,宣告彻底失恋) 跟的真紧啊。
可惜没有英文转换。
loopyifly 2003-05-07
  • 打赏
  • 举报
回复
实话说,不是我写的:

#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]]);/*输出小数部分*/
}
zhang865 2003-05-07
  • 打赏
  • 举报
回复
现在的人可真懒呀!!
功名半纸 2003-05-07
  • 打赏
  • 举报
回复
static char *pszBIG5 []= {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
static char *pszUNITS[] = {"分","角","拾","佰","仟","万"};
static char *pszAdvaUNITS[] = {"万","亿"};
//实际字符数组位置
#define BIG5_POS(n) (n - '0')

//转换10000以内的数字为大写
CString ToBIG5(UINT nValue)
{
ASSERT(nValue < 10000);
CString strRet("");
CString strValue ;
strValue.Format("%4.4u",nValue);

char chCur = 0;
int nLen = strValue.GetLength();
int cInteger = 0;
for (int i = nLen - 1; i >= 0 ; i --)
{
chCur = strValue.GetAt(i);
CString strTmp = pszBIG5[BIG5_POS(chCur)];
cInteger ++;
if (chCur != '0')
{
if (2 == cInteger )
{
strTmp += pszUNITS[2];
}
else if(3 == cInteger )
{
strTmp += pszUNITS[3];
}
else if(4 == cInteger )
{
strTmp += pszUNITS[4];
}
}
strRet = strTmp + strRet;
}
//
int nPos = 0;
int nPriorPos = 0;
bool bStartup = false;
nPos = strRet.Find(pszBIG5[0],0);
do
{
//strRet.TrimRight(pszBIG5[0]);
//strRet.TrimLeft(pszBIG5[0]);
if (strRet.Right(2) == pszBIG5[0])
{
strRet.Delete(strRet.GetLength() -2, 2);
}
nPriorPos = strRet.Find(pszBIG5[0],nPos + 2);
if (-1 == nPriorPos)
{
break;
}

if ( 2 == (nPriorPos - nPos))
{
strRet.Delete(nPos,2);
}
}while ((nPos = strRet.Find(pszBIG5[0]),nPos + 2) != -1);
if (strRet.Left(2) == pszBIG5[0])
{
strRet.Delete(0,2);
}
return strRet;
}
/*
* 将阿拉伯数字转换为大写方式
*/
CString DoubleToBIG5(double dValue)
{
CString strRet;
CString strTemp , strFloat ,strInteger;
BOOL bFloat = TRUE;
strTemp.Format("%.2f",dValue);

int nLen = strTemp.GetLength();
int i = strTemp.Find('.');
int cInteger = 0;

char chCur, chPrior ;
//转换小数点为大写
chCur = strTemp.GetAt( i + 1);
chPrior = strTemp.GetAt(i + 2);

if ('0' == chCur)
{
strFloat = pszBIG5[0] ;
if (chPrior > '0')
{

strFloat += pszBIG5[BIG5_POS(chPrior)] ;
strFloat += pszUNITS[0];
}
else
{
strFloat = "";
bFloat = FALSE;
}
}
else
{
strFloat = pszBIG5[BIG5_POS(chCur)];
strFloat += pszUNITS[1];
if (chPrior > '0')
{
strFloat += pszBIG5[BIG5_POS(chPrior)];
strFloat += pszUNITS[0];
}
}
//转换整数部分为大写
strInteger = "";
strTemp.Format("%u",(UINT)dValue);
int cRealLen = nLen -3;
int cSegments = (cRealLen) / 4;
if ((cRealLen % 4 )> 0)
{
cSegments ++;
}

for (i = 1 ; i <= cSegments ; i++)
{
CString strSwap = strTemp.Right(4);
if (strTemp.GetLength() > 4)
{
strTemp.Delete(strTemp.GetLength() - 4, 4);
}

if (i >= 2)
{
strInteger = ToBIG5(atol((LPCSTR)strSwap)) + pszAdvaUNITS[i -2 ]+ strInteger;
}
else
{
strInteger = ToBIG5(atol((LPCSTR)strSwap)) + strInteger;
}
}

if ("" == strFloat)
{
if ("" == strInteger)
{
strRet = pszBIG5[0];
strRet += "圆整" ;
}
else
{
strRet = strInteger + "圆整" ;
}
}
else
{
strRet = strInteger + "圆"+ strFloat;
}
/*
if (strRet != "" && strRet != pszBIG5[0] )
{
if (strRet.Left(2) == pszBIG5[0])
{
strRet.Delete(0 , 2);
}
}
//*/
strRet = "人民币"+ strRet;
return strRet;
}

我以前写的一个!!!!
3jaja 2003-05-07
  • 打赏
  • 举报
回复
最简单的方法:


char *c1[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char *c2[]={"亿","仟","佰","拾","万","仟","佰","拾","圆","角","分","厘"};
char c[100],china[100];
double d=123456789.321;
sprintf(c,"%.3f",d);
int i,j,k,len=strlen(c);

//find '.'
for(j=0;j<len;j++){
if(c[j]=='.'){
if(len>9)//>亿
return;
j=9-j;
break;
}
}
china[0]='\0';
for(i=0,k=0;i<len-1;i++){
if(c[i]=='.')
k++;
strcat(china,c1[c[k++]-0x30]);
strcat(china,c2[i+j]);
}
//china="壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖圆叁角贰分壹厘".
ZouMorn 2003-05-07
  • 打赏
  • 举报
回复
我也懒
meCAD 2003-05-06
  • 打赏
  • 举报
回复
String UpperMoney(double jn)
{
int L , ZL , Z , U , V;
AnsiString F = "壹贰叁肆伍陆柒捌玖" ;
AnsiString G = "元万亿万拾佰仟分角" ;
AnsiString AA , B , JNS;
JNS.SetLength(255);
double je ;

if(jn<=0)
return "零" ;

je=(jn<1?jn*100:jn);

sprintf(JNS.c_str(),"%26.2f",je) ;
JNS=TrimRight(TrimLeft(JNS)) ;

L = StrLen(JNS.c_str()) ;
L=(jn<1?(jn<0.1?1:2):L) ;

ZL = L+1 ;

AA =AnsiString("") ;
B = AnsiString("") ;

for( ;L>0; )
{
Z = StrToInt(JNS.SubString(ZL-L,1)) ;
U = int(L/4) ;
V = L%4 ;

if( Z>0 )
{
U=(V==0?U+U-1:V+V+(U>0?7:13)) ;
AA = AA+B+F.SubString(Z+Z-1,2)+G.SubString(U,2) ;
B = "" ;
}
else
{
if(L==1)
AA=AA+"整" ;
else
{
if(V==0)
AA=AA+G.SubString(U*2-1,2);
else
AA=AA+"" ;
}

B=(V>=0?"零":"") ;
}
L=(L==4?2:L-1) ;
}
return AA ;
}


服了你了.发了这么多贴子
我跟着你接分好了.你结了贴分数也不会少的.

记得头文件是
#include <stdio.h>
wbf420 2003-05-06
  • 打赏
  • 举报
回复
只要你努力,总会成功的!
内容概要:本文详细解析了2018年全国大学生电子设计竞赛C题“无线充电电动小车”的设计与实现。题目要求设计并制作一个无线充电电动车及其配套的无线充电装置,电动车需在1分钟充电后,自行启动并在平坦和倾斜路面上行驶至少1米。文中介绍了无线充电原理、DC-DC变换、超级电容选型等硬件设计要点,以及C语言编程实现的软件架构,包括充电检测、电机驱动和行驶控制等功能模块。文章还讨论了充电效率提升、行驶稳定性保障和超级电容容量匹配等难点,并提供了部分代码示例及解析。 适合人群:对电子设计竞赛感兴趣的学生、电子爱好者及初学者。 使用场景及目标:①了解无线充电原理及其实现方法;②掌握DC-DC变换技术和超级电容选型方法;③学习C语言编程技巧,特别是嵌入式系统中的中断处理和电机控制;④提高解决实际问题的能力,为参加类似竞赛做准备。 阅读建议:本文内容详尽,涵盖了从硬件设计到软件编程的各个方面。建议读者按照章节顺序逐步阅读,结合实际动手操作,深入理解每个环节的设计思路和技术细节。对于初学者,可以先从简单的硬件搭建和基础编程开始,逐步深入到复杂的系统集成和优化。

15,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧