![]() |
|
#1
|
|||
|
|||
Generating random numbersHi all,
I need to generate and store 2 arrays of 255 unique random integers each. i.e. CPP / C++ / C Code:
Both the arrays should have unique numbers and they should be in the range 1-65535. Can someone suggest some solution to this problem? Thanks, |
|
#2
|
||||
|
||||
|
The GenSeq() might be just what you are looking for. It generates a unique array for a deck of cards. You can find it in this thread.
Hope it helps. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#3
|
|||
|
|||
|
Okey,After googling for sometime, and collecting some bits and pieces of info I wrote this program. It generates 2 arrays of size 255 each with unique integer in the range 1 to 65535.
Anybody want to regress it ? CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
|
okey, here is another version. A little customized to my requirement. I have now 3 arrays, each of size 255 and with unique integer. My earlier code in previous post used to generate duplicates with multiple runs. This one takes care of that.
Not very elegent one, but working solution. CPP / C++ / C Code:
|
|
#5
|
||||
|
||||
|
I think this is about the same thing. If I find a "0" I know I have not found a match. I don't really know the proper way to pass the multidim arrays but this seems to work.
CPP / C++ / C Code:
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#6
|
||||
|
||||
|
A few changes to shut up my compiler and some printing additions.
CPP / C++ / C Code:
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
Recent GIDBlog
Python ebook by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary number systems: BCD, twos complement, ones complement, etc. | machinated | Miscellaneous Programming Forum | 6 | 08-Feb-2006 11:51 |
| Linear Search | eccoflame | C Programming Language | 3 | 19-Apr-2005 09:36 |
| Poker game and random numbers... | markersniffer21 | C++ Forum | 2 | 06-Nov-2004 09:43 |
| Help with random numbers | da_bomb50 | MySQL / PHP Forum | 3 | 04-Aug-2004 20:34 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The