China Naming Network - Ziwei Dou Shu - A shuffling algorithm written in Javascript is very simple, please read it by experts.

A shuffling algorithm written in Javascript is very simple, please read it by experts.

x=54

dim nba()

Redim nba(x)

For i=0 to x- 1

nba(i)=i

then

Child ww ()

Randomize initializes the random number generator.

For qq=0 to x- 1

A=rnd ()' generates a random number from 0 to 1.

B=int(x*a) 'int () and parseint () are integers, and a random integer from 0 to x is obtained.

c=nba(qq)

nba(qq)=nba(b)

Nba(b)=c' The above three sentences are the list items that qq and B point to.

then

End joint