zoukankan
html css js c++ java
数字翻译成英语
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <script type="text/javascript"><!-- var arr1=new Array(""," thousand"," million"," billion") var arr2=new Array("zero","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety") var arr3=new Array("zero","one","two","three","four","five","six","sever","eight","nine"); var arr4=new Array("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"); function Translate(num){ var len=num.length,i,j=0,strRet=""; var cols=Math.ceil(len/3); var first=len-cols*3 var strRet="" for(i=first;i<len;i+=3){ ++j; if(i>=0) num3=num.substring(i,i+3) else num3=num.substring(0,first+3) strEng=English(num3) if(strEng!=""){ if(strRet!="") strRet+="," strRet+=English(num3)+arr1[cols-j] } } return strRet } function English(num){ strRet="" if((num.length==3)&&(num.substr(0,3)!="000")){ if((num.substr(0,1)!="0")){ strRet+=arr3[num.substr(0,1)]+" hundred" if(num.substr(1,2)!="00")strRet+=" and " } num=num.substring(1); } if((num.length==2)){ if((num.substr(0,1)=="0")){ num=num.substring(1) } else if((num.substr(0,1)=="1")){ strRet+=arr4[num.substr(1,2)] } else{ strRet+=arr2[num.substr(0,1)] if(num.substr(1,1)!="0")strRet+="-" num=num.substring(1) } } if((num.length==1)&&(num.substr(0,1)!="0")){ strRet+=arr3[num.substr(0,1)] } return strRet; } // --></script> </HEAD> <BODY> <input id=number value=1234567890><input type=button value=翻译成英文 onclick=alert(Translate(document.all.number.value))> </BODY> </HTML>
运行代码
查看全文
相关阅读:
日期型数据知识
如何让VS检查函数和类Comment的添加情况
HTTP request is unauthorized with client authentication scheme 'Anonymous'.
将SerializableAttribute序列化为xml
使用EnterpriseLibrary Validation Block对WCF做验证
表达式树中递归方法
使用SignalR在Asp.net中实现进度条
SQLServer中列出数据库的所有表的创建时间
用Knockoutjs与Asp.net MVC实现级联下拉列表
使用UnityAutoMoq简化单元测试
原文地址:https://www.cnblogs.com/geass/p/1951484.html
最新文章
MySQL基于日志还原数据
boost 智能指针
hosts
刷机
gdb vector
jquery clone
python qt编程
vector
dojo helloworld
安装软件 palm
热门文章
palm qq
c/c++ int _tmain(int argc, _TCHAR* argv[])
没有找到MFC80D.DLL,因此这个应用程序未能启动。重新安装应用程序可能会修复问题。
HTML5闪存
如何:获取对 DTE 和 DTE2 对象的引用
IIS服务中五种身份验证的灵活运用转
如何使用C#操作WinAPI
十六进制字符串操作
VS2008 AddIn 操作DTE2
GAC简介
Copyright © 2011-2022 走看看