本帖最后由 pcl_test 于 2016-11-26 05:47 编辑
批处理的,那么看懂了么,能改动么?
http://www.bathome.net/redirect. ... 40953&ptid=6326
http://www.bathome.net/viewthread.php?tid=34193
再封装一个转换“函数”- @echo off
- rem 调用方法call :ch2num 中文小写数字 结果
- rem 最大支持九千九百九十九亿九千九百九十九万九千九百九十九
- call :ch2num 一亿二千三百四十五万四千三百二十一 result
- echo;%result%
- pause&exit
- :ch2num
- set "str=%~1"
- set "str=%str: =%"
- set str=%str:〇=零%
- setlocal enabledelayedexpansion
- for %%a in (零0 一1 二2 三3 四4 五5 六6 七7 八8 九9 十10 百100 千1000) do (
- set "n=%%a"&set "#_!n:~,1!=!n:~1!"
- )
- if "%str%" equ "零" (
- set v=0
- ) else (
- set /a s=s1=s2=0
- set str=%str:零=%
- if "!str:~,1!" equ "十" set str=一!str!
- for %%a in (亿 万) do set "str=!str:%%a=%%a !"
- for %%a in (!str!) do (
- set t=%%a
- if "!t:~-1!" equ "亿" (set f=1) else if "!t:~-1!" equ "万" (set f=2)
- if defined f set t=!t:~,-1!
- for %%b in (千 百 十) do (
- if "!t:~-1!" equ "%%b" set t=!t!零
- set "t=!t:%%b=%%b !"
- )
- for %%b in (!t!一) do (set "n=%%b"&call set /a "s!f!+=%%#_!n:~,1!%%*%%#_!n:~-1!%%")
- set "f="
- )
- set /a s+=s2*10000
- if !s1! equ 0 (set v=!s!) else (set /a s+=100000000&set v=!s1!!s:~1!)
- )
- endlocal&set "%~2=%v%"&goto :eof
复制代码
|