我也来一个吧。能生成一批四位不重复的随机数:- @echo off&setlocal enabledelayedexpansion
- ::生成四位的随机数100个
- for /l %%i in (1,1,100) do (set/a #%%i=!random!%%9000+1000)
- ::过滤掉有重复数字的随机数
- for /l %%i in (0,1,100) do (
- for /l %%j in (0,1,9) do (
- set ss=!#%%i:%%j=!
- if !ss! lss 100 (set "#%%i=")
- )
- )
- for /f "tokens=2 delims=#=" %%i in ('set #') do echo %%i
-
- pause
复制代码
|