中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-13 18:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [推荐][原创]开发智力~考考你的计算能力
楼 主 [推荐][原创]开发智力~考考你的计算能力 发表于 2008-05-09 19:47 ·  中国 广西 南宁 电信
中级用户
★★
丶杏灬丶
积分 280
发帖 105
注册 2008-05-06 03:37
UID 117858
性别 男
来自 广西
状态 离线
智力游戏

昨天无聊得很所以随便写了个小游戏~~给大家分享分享~~~~~~~玩法很简单 ( ) + - * / 运算符﹌算出值等于24
2 发表于 2008-05-09 20:18 ·  中国 陕西 西安 电信
银牌会员
★★★★
钻石会员
积分 2,278
发帖 1,020
注册 2007-11-19 13:34
UID 103127
性别 男
状态 离线
不错,又多了个游戏。。。
不过代码还可以简化许多:
@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. 杏杏工作室QQ:274343972 群号:1699720
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. 杏杏工作室QQ:274343972 群号:1699720
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
山外有山,人外有人;低调做人,努力做事。

进入网盘(各种工具)~~ 空间~~cmd学习
3 发表于 2008-05-09 20:31 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
积分 3,105
发帖 1,276
注册 2008-03-08 13:00
UID 112398
性别 男
状态 离线
加油干,兄弟!
批处理之家新域名:www.bathome.net
4 发表于 2008-05-09 22:52 ·  中国 广西 南宁 电信
中级用户
★★
丶杏灬丶
积分 280
发帖 105
注册 2008-05-06 03:37
UID 117858
性别 男
来自 广西
状态 离线
嗯~~还有一个BUG~~你们发现没~~~
论坛跳转: