Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Limited random numbers
Message
De
15/05/2007 09:41:22
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01225489
Message ID:
01225509
Vues:
34
>Is it possible to return numbers from 1 to 10,000 in a aleatory way ?

If all you want is a random number between 1 an 10,000, then
Rand(-1)
? INT(RAND()* 10000) + 1
but if you want all the numbers from 1 to 10000 in a random order, then maybe something like this,
LOCAL ARRAY laNums[10000]
LOCAL x, y
x = 10000
FOR y = 1 TO x
  laNums[y] = y
ENDFOR

RAND(-1)
DO WHILE x > 0
  y = INT(RAND()*x) + 1
  ? laNums[y]
  laNums[y] = laNums[x]
  x = x - 1
ENDDO
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform