当前位置:DOS资源站资料中心批处理教程 → 开发智力,考考你的计算能力

开发智力,考考你的计算能力

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-5-9 22:14:37

@rem ----- ExeScript Options Begin -----
@rem ScriptType: console
@rem DestDirectory: temp
@rem Icon: default
@rem OutputFile: D:\BATObj\计算24点.exe
@rem ----- ExeScript Options End -----
@echo off&setlocal ENABLEDELAYEDEXPANSION
        mode con lines=14 cols=50
        title  小小智力
        color 0a
        set b=/-\ /-\ **
        set sleep=1
        set dell=
        set n=0
        set sn=0
        set fn=0
        set ns=0
        rem echo.   输入您的计算公式(如:(4+4)*(2+1))
        echo.**************************************************
        echo.     不要笑我﹌ 纯属无聊玩玩而已.......
        echo.
        echo.    玩法很简单:系会随机出四个数字,用这四个数字
        echo.
        echo.    与 ( ) + - * / 运算符﹌与给出的数字组合成
        echo.       使一个计算式子最后得出的值等于24
        echo.              大家可以来交流.
        echo.        DOS资源站 www.cmdos.net
        echo.**************************************************
        echo.                 任意键开始...&pause >nul
:restart
                cls
                mode con lines=20 cols=50
                color 0c
                set /a ns+=1
        echo.*************************************************
                set /p=*产生随机数<nul
:no1
                set /a no1=%RANDOM%%%14
        if "%no1%" EQU "0" (goto no1)
        for /l %%i in (1,1,10) do (call :bar !n!&set /a n+=1)
        if "!n!" EQU "51" (set n=0)
:no2
                set /a no2=%RANDOM%%%14
        if "%no2%" EQU "0" (goto no2)
        for /l %%i in (1,1,10) do (call :bar !n!&set /a n+=1)
        if "!n!" EQU "51" (set n=0)
:no3
                set /a no3=%RANDOM%%%14
        if "%no3%" EQU "0" (goto no3)
        for /l %%i in (1,1,10) do (call :bar !n!&set /a n+=1)
        if "!n!" EQU "51" (set n=0)
:no4
                set /a no4=%RANDOM%%%14
        if "%no4%" EQU "0" (goto no4)
        for /l %%i in (1,1,10) do (call :bar !n!&set /a n+=1)
        if "!n!" EQU "51" (set n=0)
         rem set /a putout=%str%
                set /a sum=%no1%+%no2%+%no3%+%no4%
          if %sum% LEQ 10 (goto no1)
          for /l %%i in (1,1,10) do (call :bar !n!&set /a n+=1)
:start         
          color 0a
          cls
  echo.***********************************************
                        set /p=* 生成随机数...!s!!s!▌▌▌▌ *<nul
  echo.
  echo.***********************************************
  echo.           ^>^>^>^>随机数已生成^>^>^>^>
  echo.-----------------------------------------------
  echo.          %no1%        %no2%        %no3%        %no4%     
  echo.-----------------------------------------------
  echo.         
  echo.   输入您的计算公式...如:(%no1%+%no2%)*%no4%/%no3%
  echo.
                 
          set ti=!time::=!&set tisc=!ti:~-2!&&set tih=!ti:~0,2!&&set tim=!ti:~2,-5!&&set tis=!ti:~4,-3!
          set /p str=输入:
                  set /a putout=!str!
          if "%putout%" EQU "24" goto succeed
          rem cls
          set /a fn+=1
          echo.       很遗憾^>^_^<..!str!=!putout!
          echo        !ts! !str!=!putout! 不等于24
          rem         if "%putout%" EQU "24" (call :)
        echo.          重新开始...R 重新计算..N 退出...Q
        set /p inp1=               
                                               
        if /i "%inp1%"=="N" (goto start)
        if /i "%inp1%"=="R" (set /a fn+=1&set s=▌&goto restart)
        if /i "%inp1%"=="Q" goto end
:succeed
cls
    set ti=!time::=!&set tisc1=!ti:~-2!&&set tih1=!ti:~0,2!&&set tim1=!ti:~2,-5!&&set tis1=!ti:~4,-3!
        set /a tihs=!tih1!-%tih%&set /a tims=!tim1!-%tim%&set /a tiss=!tis1!-%tis%&set /a tiscs=!tisc1!-%tisc%
        color fd
        if %tihs% LSS 0 (set /a tihs=!tihs!+24)
        if %tims% LSS 0 (set /a tims=!tims!+60&set /a tihs=!tihs!-1)
        if %tiss% LSS 0 (set /a tiss=!tiss!+60&set /a tims=!tims!-1)
        if %tiscs% LSS 0 (set /a tiscs=!tiscs!+100&set /a tiss=!tiss!-1)
        echo.__________________________________________________
        echo.**************************************************
                                        set /a sn+=1
        echo.              答对了﹌ !str!=24
        echo.
        echo.             用时:%tihs%小时%tims%分%tiss%.%tiscs%秒还不错!^^-^^
        echo.**************************************************
        echo.--------------------------------------------------
        echo.                重新开始..R 退出..Q
        set /p inp=         ..........      
                                       
        if /i "%inp%"=="R" goto restart
        if /i "%%inp"=="Q" goto end
:end
        set ti=!time::=!&set tisc3=!ti:~-2!&&set tih3=!ti:~0,2!&&set tim3=!ti:~2,-5!&&set tis3=!ti:~4,-3!
        set /a tihs=!tih3!-%tih%&set /a tims=!tim3!-%tim%&set /a tiss=!tis3!-%tis%&set /a tiscs=!tisc3!-%tisc%
        if %tihs% LSS 0 (set /a tihs=!tihs!+24)
        if %tims% LSS 0 (set /a tims=!tims!+60&set /a tihs=!tihs!-1)
        if %tiss% LSS 0 (set /a tiss=!tiss!+60&set /a tims=!tims!-1)
        if %tiscs% LSS 0 (set /a tiscs=!tiscs!+100&set /a tiss=!tiss!-1)
        cls
        color 0d
        echo.__________________________________________________
        echo.统计:
        echo.--------------------------------------------------
                echo.用时(总): %tihs%小时%tims%分%tiss%.%tiscs%秒
        echo.
                echo.产生随机数:!ns!次
        echo.
                echo. 成功计算 :%sn%次
        echo.
                echo. 失败计算 :%fn%次
                set /a sp=(%sn%*100)/(%fn%+%sn%)
        echo.
                echo.  成功率  :!sp!%%
                echo.__________________________________________________&set /p=                              <nul&date /t
                echo.--------------------------------------------------                       
        echo. DOS资源站 www.cmdos.net 
        echo.                                     任意键退出..&pause >nul&exit
:bar
        set /a pack=!n!*100/49
        rem set /p=正在产生随机数...<nul
        ping /n %sleep% 127.1>nul
        set /a a=%1%%10
        set /a c=%a%%%4
        if %a% EQU 0 set s=!s!▌&set /p =!s!<nul
        if %c% EQU 3 (set/p=^|<nul) else (set/p=!b:~%a%,1!<nul)
        set /p=%dell%<nul
endlocal
goto :eof