中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-14 13:22
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Joint Participation][Challenge Idea] Batch processing to realize conversion of digital amount to uppercase
Printable Version  14,358 / 24
Floor1 无奈何 Posted 2007-01-01 05:58
荣誉版主 Posts 356 Credits 1,338
I see that there are more and more discussions about challenging batch processing algorithms in the forum, and there are also a group of brothers who are enthusiastic about exploring the potential of batch processing. I am very happy that some tasks not very suitable for batch processing are gradually being completed by batch processing.

Now I plan a topic - converting digital amounts to uppercase. This topic can almost find versions in any popular language on the Internet, but there is a lack of a batch processing version. Of course, we can't expect foreigners to do this, and then we can learn from it ^_^.

The rules are as follows:
1. Receive a string of amount numbers and convert them to uppercase. The possible reasonable formats are 5821564130 or 5821564.130 or 5,821,564.130, etc.
There will be no numbers with unclear decimal places such as 58.215.64.130 or other non-amount digital characters.
2. The maximum digit is up to one hundred billion, and the minimum digit is up to cents, and the digits after cents are ignored.
3. It should be completed purely by batch processing under CMD without using third-party tools.
4. The specific conversion basis is as per the appendix.

Appendix:

Basic Regulations for Correctly Filling Out Bills and Settlement Vouchers


Bills and settlement vouchers filled out by banks, units, and individuals are important bases for handling payment settlements and cash receipts and payments, directly related to the accuracy, timeliness, and safety of payment settlements. Bills and settlement vouchers are accounting vouchers for banks, units, and individuals to record accounts, and are a written certificate for recording economic business and clarifying economic responsibilities. Therefore, when filling out bills and settlement vouchers, they must be standardized and standardized, with complete elements, correct numbers, clear handwriting, no omissions or mistakes, no scribbles, and prevention of alteration.
1. Chinese capital amount numbers should be filled in with regular script or running script, such as壹 (壹), 贰 (貳), 叁 (參), 肆 (肆), 伍 (伍), 陆 (陸), 柒, 捌, 玖, 拾, 佰, 仟, 万 (萬), 亿, 元, 角, 分, 零, 整 (正), etc. Words like 一, 二 (两), 三, 四, 五, 六, 七, 八, 九, 十, 念, 毛, 另 (or 0) should not be used, and simplified characters should not be made up. If complex characters such as 贰, 陆, 亿, 万, 圆 are used in the writing of amount numbers, they should also be accepted.
2. If the Chinese capital amount number ends with "yuan", the word "整" (or "正") should be written after "yuan". After "jiao", the word "整" (or "正") may not be written. If there is "fen" in the capital amount number, the word "整" (or "正") is not written after "fen".
3. The words "Renminbi" should be marked before the Chinese capital amount number. If there is "fen" in the capital amount number, the word "整" (or "正") is not written after "fen".
4. The words "Renminbi" should be marked before the Chinese capital amount number. The Chinese capital amount number should be filled in immediately after the words "Renminbi" without leaving blanks. If the words "Renminbi" are not pre-printed in the capital amount column of bills and settlement vouchers, the words "Renminbi" should be added. The fixed words such as 仟, 佰, 拾, 万, 仟, 佰, 拾, 元, 角, 分 should not be pre-printed in the capital amount column of bills and settlement vouchers.
5. When there is "0" in the Arabic lowercase amount number, the Chinese capital should be written according to the rules of the Chinese language, the composition of the amount number, and the requirement to prevent alteration. Examples are as follows:
(1) When there is "0" in the middle of the Arabic number, the Chinese capital amount should write the word "zero". For example, ¥1,409.50 should be written as Renminbi壹仟肆佰零玖元伍角.
(2) When there are several consecutive "0" in the Arabic number, only one word "zero" can be written in the middle of the Chinese capital amount. For example, ¥6,007.14 should be written as Renminbi陆仟零柒元壹角肆分.
(3) When the ten-thousand digit or yuan digit of the Arabic amount number is "0", or there are several consecutive "0" in the middle of the number, and the ten-thousand digit and yuan digit are also "0", but the thousand digit and jiao digit are not "0", only one zero word can be written in the Chinese capital amount, or the word "zero" may not be written. For example, ¥1,680.32 should be written as Renminbi壹仟陆佰捌拾元零叁角贰分, or written as Renminbi壹仟陆佰捌拾元叁角贰分; another example, ¥107,000.53 should be written as Renminbi壹拾万柒仟元零伍角叁分, or written as Renminbi壹拾万零柒仟元伍角叁分.
(4) When the jiao digit of the Arabic amount number is "0" and the fen digit is not "0", the word "zero" should be written after "yuan" in the Chinese capital amount. For example, ¥16,409.02 should be written as Renminbi壹万陆仟肆佰零玖元零贰分; another example, ¥325.04 should be written as Renminbi叁佰贰拾伍元零肆分.
5. The Chinese yuan symbol "¥" (or cursive: ¥) should be filled in before the Arabic lowercase amount number. The Arabic lowercase amount number should be filled in carefully, and should not be written continuously and unclear.


Hexadecimal relationship table:

┌─┬─┬─┬───┐
│Small│Simple│Complex│ Hexadecimal │
├─┼─┼─┼───┤
│One│壹│壹│ 1 │
├─┼─┼─┼───┤
│Two│贰│貳│ 2 │
├─┼─┼─┼───┤
│Three│叁│叄│ 3 │
├─┼─┼─┼───┤
│Four│肆│肆│ 4 │
├─┼─┼─┼───┤
│Five│伍│伍│ 5 │
├─┼─┼─┼───┤
│Six│陆│陸│ 6 │
├─┼─┼─┼───┤
│Seven│柒│柒│ 7 │
├─┼─┼─┼───┤
│Eight│捌│捌│ 8 │
├─┼─┼─┼───┤
│Nine│玖│玖│ 9 │
├─┼─┼─┼───┤
│Ten│十│拾│ 10 │
├─┼─┼─┼───┤
│Hundred│佰│佰│ 100 │
├─┼─┼─┼───┤
│Thousand│仟│仟│ 1000 │
├─┼─┼─┼───┤
│Ten thousand│万│萬│ 10^4 │
├─┼─┼─┼───┤
│Hundred million│亿│億│ 10^8 │
├─┼─┼─┼───┤
│Trillion│兆│兆│ 10^12│
└─┴─┴─┴───┘

For details: http://wiki.keyin.cn/index.php?title=%E4%B8%AD%E6%96%87%E6%95%B0%E5%AD%97&variant=zh-cn
Floor2 youxi01 Posted 2007-01-01 12:02
高级用户 Posts 247 Credits 846 From 湖南==》广东
Wrote a piece of code that in the end even I "can't understand":


[ Last edited by youxi01 on 2007-1-1 at 11:04 PM ]
Floor3 tigerpower Posted 2007-01-01 12:43
中级用户 Posts 99 Credits 377
Hehe, amazing!!!!
There are 63 lines after removing blank lines, not very long!!!!
It's wonderful to be able to write such a program with pure batch processing, amazing!!!! Admiring!!!!

The only two minor drawbacks are:
1. "十", "百", "千" should be "拾", "佰", "仟", this is a Chinese language issue, should not be considered a bug :)
2. There seems to be some issues when the input is 0.xx
Floor4 youxi01 Posted 2007-01-01 12:50
高级用户 Posts 247 Credits 846 From 湖南==》广东
Thanks for the reminder from the upstairs, it has been corrected!
Floor5 无奈何 Posted 2007-01-01 12:54
荣誉版主 Posts 356 Credits 1,338
RE youxi01
Brother's code conversion effect is very good.

Preliminary test, very compliant with the requirements, plus points for encouragement.

There is also a suggestion. When posting a complete batch processing of functions, it is recommended to attach your own name and source address, etc. When multiple reposts are made, others will not be distressed because there is no way to contact the author when they find problems or want to communicate with the author, and of course, it will better protect your work. The recommended format is "Author@Forum" and so on. The above is just a suggestion for reference.

RE tigerpower
Numbers starting with zero are not reasonable amounts and can be ignored. Of course, it is not very difficult to remove them.

[ Last edited by 无奈何 on 2007-1-1 at 01:05 PM ]
Floor6 qzwqzw Posted 2007-01-02 00:23
银牌会员 Posts 636 Credits 2,343
Join in the fun

Adopt the principle of step-by-step replacement, on the one hand, simplify the algorithm, on the other hand, it is easy to control (such as the replacement of zero yuan - yuan zero)

Deliberately omitted the term "trillion" because there are very few RMB amounts with such a large value

Moreover, there are multiple interpretations of terms like "jing" and "trillion"

Many times one trillion equals one million (1M), and sometimes one trillion equals one hundred million million

Is there anyone interested in compiling a reverse conversion algorithm?

And the mutual conversion between Roman numerals and Arabic numerals?



[ Last edited by qzwqzw on 2007-1-1 at 11:29 AM ]
Floor7 无奈何 Posted 2007-01-02 01:02
荣誉版主 Posts 356 Credits 1,338
RE qzwqzw

Brother's code is also very excellent and extremely concise.
There will be errors when there are "," in the amount, and "," is also a reasonable amount character, please improve it a little.

The concept of "兆" is different between traditional Chinese and international units. In traditional Chinese, it is 1000000000000.
For details, you can refer to the link given in the next floor.

[ Last edited by 无奈何 on 2007-1-2 at 01:10 AM ]
Floor8 qzwqzw Posted 2007-01-02 01:28
银牌会员 Posts 636 Credits 2,343
Added some verification code, which has a great impact on the conciseness of the code, a bit郁闷

Can pass numbers with prefix 0, numbers with commas, decimals with. prefix

Can prohibit amounts containing illegal characters
-----------------------------------------------------------------

The magnitude of the international unit does not have giga, only m/K/M, etc.

It is very difficult to verify who first translated M as "giga"
But now it is very popular, and some accounting textbooks have begun to adopt it
------------------------------------------------------------------------

As for the traditional Chinese counting, you can use "hundred million, giga, jing, gai" Baidu it
--------------------------------------------------------------------------



[ Last edited by qzwqzw on 2007-1-1 at 12:36 PM ]
Floor9 无奈何 Posted 2007-01-02 12:54
荣誉版主 Posts 356 Credits 1,338
RE qzwqzw

A brief understanding: traditional counting is in decimal. The above table is called the current commonly used one, which seems appropriate. Extremely large numbers are not commonly used either, just as anecdotal knowledge.
Floor10 qzwqzw Posted 2007-01-03 01:54
银牌会员 Posts 636 Credits 2,343
Made a simple example of converting Arabic numerals to Roman numerals

Considering the inconsistency of rules and the complexity of the algorithm, it does not support conversions like 49->IL

Also does not support numbers exceeding 4000

Reverse conversion is relatively more difficult

But once a good data structure is established, the algorithm is clear



[ Last edited by qzwqzw on 2007-1-2 at 01:17 PM ]
Floor11 HUNRYBECKY Posted 2007-01-03 02:05
银牌会员 Posts 442 Credits 1,179
Admiring this great work.
Floor12 tghksj Posted 2007-01-03 03:26
社区乞丐 Posts 90 Credits -49
Why is it again qzwqzw

I'm almost becoming your FANS now.

You write a piece of code, which can keep me occupied for a day or two....

As usual, add two points, take it home to read...
Floor13 flamey Posted 2007-01-03 04:51
初级用户 Posts 74 Credits 152
qzwqzw~~~~Impressive!!!!!
Floor14 qzwqzw Posted 2007-01-03 23:40
银牌会员 Posts 636 Credits 2,343
```

```
Floor15 namejm Posted 2007-01-03 23:47
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Hehe, qzwqzw is amazing. It is suggested to start special threads for publishing various types of conversions, making each thread dedicated to a specific use. This is conducive to in-depth discussions and forum retrieval in the future.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023