自己写的,谁能帮我简化一下?感觉用4个set和call set部分太重复了。
而且这个只能处理一千以下的。要能处理很大的数,该怎么改进。提提意见啊
1.txt的内容随便写几个:
一百零五
一百二十
九十八
五
- @echo off&setlocal enabledelayedexpansion
- set n=0
- for %%i in (零 一 二 三 四 五 六 七 八 九 十) do (
- set %%i=!n!
- set /a n+=1
- set /a n=!n! %% 10
- )
-
- for /f %%a in (1.txt) do (
- set s=%%a
- set s1=!s:~0,1!
- set s2=!s:~1,1!
- set s3=!s:~2,1!
- set s4=!s:~3,1!
- call set x1=%%!s1!%%
- call set x2=%%!s2!%%
- call set x3=%%!s3!%%
- call set x4=%%!s4!%%
- if "!s3!"=="" set x3=
- if "!s2!"=="百" (set x=!x1!!x3!!x4!) else (set x=!x1!!x3!)
- echo !x!
- )
- pause
复制代码
|