第二题:- @echo off&setlocal enabledelayedexpansion
- for %%a in (red green yellow blue) do set /a n+=1&set "color!n!=%%a"
- for /f "skip=2 delims=" %%a in (pic.txt) do (
- set "num="&set /a n=0
- for %%b in (%%a) do (
- if defined num (
- set /a n+=1&set "!num!-!n!=%%b"
- ) else (
- set "num=%%b"
- )
- )
- )
- :begin
- for /l %%a in (1,1,8) do (
- set /a a=!random!%%4+1
- for %%b in (!a!) do set "#%%a=!color%%b!"
- )
- for /l %%a in (1,1,8) do (
- set /a a=%%a-1
- if !a! neq 0 for /l %%b in (1,1,!a!) do if !%%a-%%b! equ 1 if !#%%a! equ !#%%b! goto begin
- )
- for /l %%a in (1,1,8) do echo %%a:!#%%a!
- pause>nul
复制代码
[ 本帖最后由 batman 于 2009-10-30 22:48 编辑 ] |