Displays a random number of 5 _dos/bat

Source: Internet
Author: User
Tags goto
Copy Code code as follows:

@echo off
:: To find 1-100 of the range of random 5 different values
:: Generating a random sequence between 0-99 R1
::
::
::
@echo off
Setlocal enabledelayedexpansion
:: Initialization sequence sequence
FOR/L%%i in (0,1,99) do (
Set rnum%%i=%%i
)
:: Random exchange of sequence
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
:: Because of the use of the echo|find structure, the speed is relatively slow
::
: Begin
Cls
Set count=0
: Loop
set/a num=%random%%%100+1
echo%str%|find "%num%" >nul&&goto loop
Call Set str=%%str%%%num%
set/a count+=1
If%count% LSS 5 goto Loop
Echo%str%
Set str=
Pause
Goto BEGIN

@echo off&setlocal enabledelayedexpansion
::
::
FOR/L%%a in (1;1;5) do (
set/a b=!random!%%99+1
Call:p P!b!
)
Goto:eof
:p P
If not defined%1 (set%1=a) Else Goto loop
Echo%1
Goto:eof
: Loop
set/a b=!random!%%99+1
Call:p P!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%) does call set/p=%%random_%%n%%<nul
Echo.
Pause
Goto Start
Exit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.