好,那我就出新的对策,看代码。横竖打乱后,再多次随机调换数字。- @echo off
- title made by cn-dos and bathome - 523066680
- setlocal enabledelayedexpansion
- :start
- set h1=123456789
- set h2=234567891
- set h3=345678912
- set h4=456789123
- set h5=567891234
- set h6=678912345
- set h7=789123456
- set h8=891234567
- set h9=912345678
-
- for /l %%a in (0,1,9) do (
- set Ex%%a=
- set Ex2%%a=
- set hang%%a=
- )
-
- set /a a=0,b=0,c=0
- ::a ---把列打乱
- :a
- set /a a+=1
- :a-1
- set n=%random:~-1%
- if %n% equ 9 set n=8
- if not defined Ex%n% (
- for /l %%a in (1,1,9) do (call,set hang%%a=!hang%%a! %%h%%a:~!n!,1%%)
- ) else (goto :a-1)
- set Ex%n%=ex
- if %a% lss 9 goto :a
- ::b ---把行打乱
- :b
- set /a b+=1
- :b-1
- set n=%random:~-1%
- if %n% equ 0 set n=9
- if not defined Ex2%n% (set h%b%=!hang%n%!) else (goto :b-1)
- set Ex2%n%=ex
- if %b% lss 9 goto :b
- ::c ---随机调换数字
- :c
- set /a c+=1
- :c-1
- set n1=!random:~-1!
- set n2=!random:~-1!
- if %n1% equ %n2% goto :c-1
- if %n1% equ 0 set n1=1
- if %n2% equ 0 set n2=9
- for /l %%a in (1,1,9) do (
- set h%%a=!h%%a:%n1%=n!
- set h%%a=!h%%a:%n2%=%n1%!
- set h%%a=!h%%a:n=%n2%!
- )
- if %c% lss 8 goto :c
- for /l %%a in (1,1,9) do echo !h%%a!
- pause
- goto :start
复制代码 但也出现
8
8
8
这样的情况,不过大家的代码偶尔也出现这种情况 好像很难避免了
[ 本帖最后由 523066680 于 2008-8-18 08:04 编辑 ] |