- @echo off&color c0&title 算24
- setlocal ENABLEDELAYEDEXPANSION
- ::from 771815005
- :number1
- set /a shu1=%random%%%11
- if "%shu1%"=="0" goto number1
- :number2
- set /a shu2=%random%%%11
- for %%b in (%shu1% 0) DO if %shu2%==%%b goto number2
- :number3
- set /a shu3=%random%%%11
- for %%j in (%shu1% %shu2% 0) DO if %shu3%==%%j goto number3
- :number4
- set /a shu4=%random%%%11
- for %%h in (%shu1% %shu2% %shu3% 0) DO if %shu4%==%%h goto number4
- echo.&echo 请用%shu1% %shu2% %shu3% %shu4%算出24。
- echo.&echo S键跳过,E键退出。
- :input
- Echo.&Set /p suan=请输入算式:&cls&echo.
- echo 验证中,请稍候...&echo.
- if "%suan%"=="" goto input
- if %suan%==s cls&goto number1
- if %suan%==e cls&echo.&Echo goodbye!&pause>nul&exit
- set suan=%suan:[=(%
- set suan=%suan:]=)%
- set /a jieguo="%suan%"&set tp=0
- for /l %%i in (1 1 4) do (
- echo "%suan%"|find "+!shu%%i!">nul||echo "%suan%"|find "-!shu%%i!">nul||^
- echo "%suan%"|find "*!shu%%i!">nul||echo "%suan%"|find "/!shu%%i!">nul||^
- echo "%suan%"|find "(!shu%%i!">nul||set /a tp+=1
- )
- if not "%suan:~0,1%"=="(" set /a tp-=1
- if %jieguo% equ 24 if %tp% lss 1 goto yes
- :no
- echo 啊,不对!&goto next
- :yes
- echo Yes,对了!
- :next
- echo.&echo 下一题...
- pause>nul&cls&goto number1
复制代码
2008.09.29更新
[ 本帖最后由 yslyxqysl 于 2008-9-29 14:57 编辑 ] |