1到10的随机排列- @echo off
- setlocal enableDelayedExpansion
-
- rem 1..10
- for /l %%a in (1,1,10) do (
- set _%%a=x%%a
- )
- echo sequences
- for /l %%a in (1,1,10) do (
- echo !_%%a!
- )
-
- rem 随机
- for /l %%a in (1,1,9) do (
- call :f %%a 10
- )
- echo random
- for /l %%a in (1,1,10) do (
- echo !_%%a!
- )
- goto :END
-
- :f
- set /a n=%random%%%(%2-%1+1)+%1
- if %n%==%1 goto :eof
- set t=!_%n%!
- set _%n%=!_%1!
- set _%1=%t%
- goto :eof
-
-
- :END
复制代码
|