求一bat
bat吧
全部回复
仅看楼主
level 9
要在1到70之间随机选出40个不重复数字。应该很简单,帮忙!
2015年05月15日 16点05分 1
level 9
不难吧。。。
2015年05月15日 16点05分 2
level 11
1
2015年05月15日 16点05分 3
level 14
@echo off
setlocal enabledelayedexpansion
for /l %%i in () do (
 set /a num=!random! %% 70 +1
 if not defined _!num! (
  echo !num!
  set /a _!num!=0,n+=1
 )
 if "!n!"=="40" call :next
)
:next
pause
2015年05月15日 23点05分 4
谢了!
2015年05月16日 05点05分
卧槽看了半天才知道是添加变量名来排除数
2015年05月16日 13点05分
大神好,请教set /a _!num!=0,这里的下划线起到什么作用?谢谢
2015年06月28日 06点06分
2015年06月28日 07点06分
level 13
楼上正解[吐舌]
2015年05月16日 01点05分 5
level 13
:: 一种奇怪的写法^
百度吞缩进
@echo off
setlocal enabledelayedexpansion
for /l %%i in (0,1,39) do ^
(
call :rand
set a_!errorlevel!=1
echo !errorlevel!
)
pause
exit
:rand void
set /a is=%random% %% 70 +1 ^
if defined a_%is%
goto rand ^
else ^
exit /b %is%
2015年06月28日 07点06分 10
1