将数字转换为特殊字格式 [英] Convert number to special word format

查看:86
本文介绍了将数字转换为特殊字格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助才能将数字转换为特殊的单词格式。



例如,假设我有数字2,000,我想将其转换为< b>两千。很简单。现在......让我说我的号码是23,000 ......我想将它转换为两三千。 15,500将被转换为一个五千五百,依此类推。

解决方案

有很多例子,例如< a href =http://www.google.com/#q=number+to+word+codeproject.com> Google [ ^ ]返回:

将数字转换为英文和亚洲格式的单词 [ ^ ]

您需要两个单独的功能:您拥有的功能和将数字转换为数字字序列的功能: NumberToDigitWords(23) => 两个三个

然后在主 NumberToWords 中,在地方拨打 NumberToDigitWords 你希望 行为,而不是简单地递归调用 NumberToWords


I need some help with converting numbers to a special word format.

For example, let's say I have the number 2,000, I want to convert it to two thousand. Simple enough. Now...let's say I have the number 23,000...I want to convert it to two three thousand. 15,500 would be converted to one five thousand five hundred, so on and so forth.

解决方案

There are tons of examples, for example Google[^] returns:
Convert numbers to words in English and Asian format[^]


You need two separate functions: the one you have and one that converts numbers to the sequence of digit words: NumberToDigitWords(23) => "two three"
Then in the main NumberToWords, call the NumberToDigitWords in the places where you want that behavior, instead of simply calling NumberToWords recursively.


这篇关于将数字转换为特殊字格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆