- @echo off&setlocal enabledelayedexpansion
- set /a 赢=平=输=0,#.1=#2=1,n=10000
- set #_1=剪刀&set #_2=石头&set "#_3= 布 "
- :start
- set c=&set /p c=请出拳[1剪刀、2石头、3布]:&cls
- if not defined c (goto end) else (
- echo;%c%|findstr "^[123]$">nul||(echo;输入有误!请重新输入&echo;&goto start)
- )
- set /a r=%random%%%3+1,t=c-r,n+=1
- if %t% equ 0 (set v=平) else if !#%t:-=.%! equ 1 (set v=输) else (set v=赢)
- set /a %v%+=1&set _%n%=第%n:~-3%局:玩家[!#_%c%!] %v%{!%v%!} 电脑[!#_%r%!]
- echo;!_%n%!&echo;&goto start
- :end
- echo;Game Over&echo;[赢:%赢% 平:%平% 输:%输%]
- echo;----------------------------------------
- for /f "tokens=2,4 delims=={}" %%a in ('2^>null set _') do echo;%%a%%b
- pause
复制代码
|