![]() |
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:
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 |