Hi thanks for the feedback but can u write a code for me for the output that i want. if you write code then i will ammend it according to my template. Actually i am working on one c++ template, so it would be easy for me if you provide me a simple code and then i will apply it on my template.
Why should someone else write your code for you ?
Lerner's already given you the actual ways you can go with the Logic, you just have to convert that in to your code.
As far as the way you should go, I suggest you follow the second method which Lerner suggested, hold a vector which contains the unused numbers in your range and remove each number once it gets used in your actual array.
Also to generate your number I suggest you use
rand()%X , where X-> size of Vector; this would give you the number at which index in the Vector to use, and once you have used the element at that index, just "erase" it from the vector, As a result "X"(size of the vecor) would keep on decrementing and you will mostly not have to worry about
rand() repeating values.
In case you want help with Vectors you can look
here.
Last edited by stephen84s; Jun 29th, 2008 at 7:13 am.
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
Offline 1,316 posts
since Jul 2007