• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    显示随机的5个数
    复制代码 代码如下:

    @echo off
    :: 求1-100范围内随机的不同5个数值
    :: 生成0-99之间的随机数列 R1
    ::
    ::
    ::
    @echo off
    setlocal EnableDelayedExpansion
    :: 初始化顺序数列
    for /l %%i in (0,1,99) do (
    set rnum%%i=%%i
    )
    :: 对数列进行随机交换
    for /l %%i in (0,1,99) do (
    set /a rnd=!random! %% 100
    call set tmp=%%rnum!rnd!%%
    set rnum!rnd!=!rnum%%i!
    set rnum%%i=!tmp!
    )
    set rnum
    pause
    goto :eof

    @echo off
    :: Code by JM 2006-1-5 CMD@XP
    :begin
    cls
    set times=0
    set count=0
    :loop
    set /a num=%random%%%99+1
    if not defined num%num% (
    set num%num%=%num%
    set /a count+=1
    call echo %%num%%
    )
    set /a times+=1
    if %times% equ 20 (
    for /l %%i in (1,1,99) do set num%%i=
    set times=0
    )
    if %count% lss 5 goto loop
    pause>nul
    goto begin
    @echo off
    :: Code by JM 2007-1-6 CMD@XP
    :: 因为用到了 echo|find 的结构,速度比较慢
    ::
    :begin
    cls
    set count=0
    :loop
    set /a num=%random%%%100+1
    echo %str%|find " %num% ">nulgoto loop
    call set str=%%str%% %num%
    set /a count+=1
    if %count% lss 5 goto loop
    echo %str%
    set str=
    pause
    goto begin

    @echo offsetlocal enabledelayedexpansion
    ::
    ::
    for /l %%a in (1;1;5) do (
    set/a b=!random!%%99+1
    call :pp !b!
    )
    goto :eof
    :pp
    if not defined %1 (set %1=a) else goto loop
    echo %1
    goto :eof
    :loop
    set/a b=!random!%%99+1
    call :pp !b!

    @echo off
    ::
    ::
    set Max=100
    set N=5
    :start
    cls
    echo %time%
    set Num=
    set Tmp$=
    :loop
    set /a randomloop=(%random%+%random%+%random%)/3%%%Max%+1
    for %%n in (%Tmp$%) do if "%randomloop%" == "%%n" goto loop
    call set Tmp$=%%Tmp$%% %randomloop%
    set /a Num+=1
    set random_%Num%=%randomloop%
    if %Num% LSS %N% goto loop
    echo %Tmp$%
    echo %time%
    pause
    goto start
    exit

    @echo off
    ::
    ::
    :start
    cls
    set Num=
    set Tmp$=
    :loop
    set /a randomloop=%random%%%99+1
    for %%n in (%Tmp$%) do if "%randomloop%" == "%%n" goto loop
    call set Tmp$=%%Tmp$%% %randomloop%
    set /a Num+=1
    set random_%Num%=%randomloop%
    if %Num% LSS 5 goto loop
    for /l %%n in (1,1,%Num%) do call set /p= %%random_%%n%%nul
    echo.
    pause
    goto start
    exit
    上一篇:显示某两个字符及之间的字符
    下一篇:查找偶数行内容的批处理
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    显示随机的5个数 显示,随机,的,5个数,显示,