i am troubling myself too much time now with this rand().
I want to add 1000
random numbers in an array, this is what i have so far, it works ith no error, but rand assigns all the time the same number in the arrays passing. the vary of the random numbers i want it to be from 1 to 999... any ideas whats going wrong?
btw i am running in ksh...
nawk ' BEGIN{
for (i=0; i<=999; i++) {
srand()
NUMBERS[i]= int(rand()*(999))
print NUMBERS[i]
}
}'
P.S. Not a dublicate, no other same question for ksh.
UPDATED
nawk ' BEGIN{
srand(1)
for (i=0; i<=999; i++) {
NUMBERS[i]= int(rand()*(999))
XNUMBERS[i]= int(rand()*(999))
print NUMBERS[i]
print XNUMBERS[i]
}
}'
Aucun commentaire:
Enregistrer un commentaire