- @echo off & setlocal EnableDelayedExpansion
- set str=2 0 50000 50 0 20 4 1000 0 10 30 0 500 0 100 50000 2 0 1000 50 0 2 0 10 500 30 0 2 70 0 1000 100
-
- :bgn
- set RMB=
- set token=
- set /p input=号码:
- for /l %%a in (0 1 4) do (
- set /a 1/!input:~%%a,1! 2>nul || goto error
- set /a token+=!input:~%%a,1!
- if !token! gtr 32 goto error
- call :money !token!
- )
-
- echo 中奖金额: %RMB%
- echo.
- goto bgn
-
- :error
- cls & echo 输入错误。请按任意键返回. . .
- pause>nul & cls & goto bgn
-
- :money
- if %1 equ 32 set /a "RMB+=100" & goto :eof
- for /f "tokens=%1" %%a in ("%str%") do set /a RMB+=%%a
复制代码 做了这个题目才知道在 for /F 中,tokens 的值不能大于 31... |