凑热闹- ::随机选双色球
- :: @随风 @bbs.bathome.net @2010-09-04
-
- @echo off & setlocal enabledelayedexpansion
- ::初始化数列
- for /l %%i in (1 1 33) do set sj%%i=%%i
-
- ::获取随机红色球
- for /l %%L in (1 1 5) do (
- call :Loop
- set "str="
- set /a w=!random! %% 16+101
- for /l %%i in (1 1 6) do (
- set n=0!sj%%i!
- set n=!n:~-2!
- set str=!str! !n!
- )
- call :sort0 "!str!" ok
- echo !ok! + !w:~-2!
- )
- pause
- exit
-
- ::给红球排序
- :sort0 排除法 可排序200位以内整数、0、负数、重复数(封装)
- ::位数越少速度越快默认20位 by 随风 @bbs.bathome.net @2009-02-28
- setlocal enabledelayedexpansion&set w=20&set k=&set m=%~1
- set lin=$$$$$$$$$$&set "lin=!lin!!lin!!lin!!lin!"
- set lin=!lin!!lin!!lin!!lin!!lin!&set kf=&set "h="
- for %%a in (!m!)do (set f=%%a&(if "!f:~0,1!"=="-" (
- set f=!lin!!f:~1!&set "h=!h! a!f:~-%w%!"
- ) else (set f=!Lin!%%a&set h=!h! $!f:~-%w%!)))
- (for %%a in (!m!)do (set n=$&set s=&(for %%i in (!h!)do (
- if "%%i" geq "!n!" (set s=%%i !s!&set n=%%i)else set s=!s! %%i))
- set h=!s:* =!&set n=!n:$=!&if "!n:~0,1!"=="a" (
- set kf=!kf! !n:a=-!) else set k=!n! !k!))&set "k=!kf! !K!"
- endlocal&set %~2=%k:~1,-1%&goto :EOF
-
- :loop
- :: 对数列进行随机交换
- for /l %%i in (1,1,33) do (
- set /a x=!random! %% 33+1
- for %%j in (!x!) do set tmp=!sj%%j!
- set sj!x!=!sj%%i!
- set sj%%i=!tmp!
- )
- goto :EOF
复制代码
|