char0 Posted October 15, 2013 Posted October 15, 2013 (edited) Hello, I'm trying to generate random numbers not repeated for an array ".p" using the same size an array ".s$". But the NPC is accusing infinite loop. How could I generate numbers not repeated 0-19 without error? Grateful for help, Char0. Edited October 15, 2013 by char0 Quote
Emistry Posted October 15, 2013 Posted October 15, 2013 you can try this http://upaste.me/r/7c658f 1 Quote
Capuche Posted October 15, 2013 Posted October 15, 2013 I don't understand what you wanted to do but about How could I generate numbers not repeated 0-19 without error? setarray .@tmp, 0,1,2,3,4,5; .@size = 6; while( .@size ) { .@r = rand( .@size );// pick a number between 0-19 set .p[.@i], .@tmp[.@r]; deletearray .@tmp[.@r],1; .@size--; .@i++; } 1 Quote
char0 Posted October 15, 2013 Author Posted October 15, 2013 Thank Capuche and Emistry. The Emistry code worked fine, but both were very helpful. Quote
Question
char0
Grateful for help, Char0.
Edited by char03 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.