Thank you everyone! You've worked hard!!!
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
:: Generate a random sequence R1 between 0 - 99
:: qzwqzw@bbs.cn-dos.net
:: 2007-01-04 23:03
@echo off
setlocal EnableDelayedExpansion
:: Initialize the sequential sequence
for /l %%i in (0,1,99) do (
set rnum%%i=%%i
)
:: Randomly swap the 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
| Rater | Score | Time |
|---|---|---|
| 26933062 | +2 | 2007-01-06 12:29 |

Originally posted by tghksj at 2007-1-5 14:42:
Another idol of mine, qzwqzw~~
I can't understand the 32nd floor... I can't take it anymore... I have to read each of your codes for a day or two...
Please explain each sentence one by one, okay??? Mom, I can't take it anymore~!!!
--- ...
Originally posted by lxmxn at 2007-1-5 12:47:
After multiple tests, I found that the code on floor 13 is very strange. The first number among the five numbers in the result is easily the same as the first number in the next test result. I don't know the reason. Maybe there is a problem with the code.
Originally posted by 26933062 at 2007-1-5 21:50:
Yes, moderator, I tested the code on floor 6 many times and found that there are still duplicate phenomena.
@echo off
: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
set count=1
set num=
echo %random% >nul
:DORND
set /a rnd=%random%*100/32767+1
echo %num% | find " %rnd% " && goto DORND
set num=%num% %rnd%
set /a count+=1
if %count% lss 6 goto DORND
echo %num%
pause
Originally posted by lxmxn at 2007-1-5 12:47 PM:
After multiple tests, it is found that the code on floor 13 is very strange. The first number among the five numbers in the result is very easy to be the same as the first number in the next test result. I don't know what the reason is..
@echo off
set count=1
:loop
echo %random% & echo.
set /a count+=1
if %count% lss 10 goto loop
pause
Originally posted by dikex at 2007-1-6 01:02:
Just to join in the fun, I'll post one too
Everyone may find the fourth line strange. For this, please see the following question from xmxn and my personal insights
This seems to be a problem with the method of generating random numbers...
@echo off&setlocal enabledelayedexpansion
for /l %%a in (1,1,20) do echo !random!
pause