User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 425,816 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,081 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums

Array without twice the same number?

Join Date: Sep 2004
Posts: 411
Reputation: JoBe is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 3
JoBe's Avatar
JoBe JoBe is offline Offline
Posting Pro in Training

Array without twice the same number?

  #1  
Oct 22nd, 2004
Hi ladies and gentlemen,

Gotta question,

I have a program in wich I make a small array of 100 random numbers wich are smaller then 1000!

Like this:
# define MAX 100

void srand(int tabel[MAX]);

void srand(int tabel[MAX])
{
for (int i=0;i<MAX;i++)
do
tabel[i]=rand();
while (tabel[i]>1000);
}

This of course is only one part of the program and as you can see this array is made with a function! Now, this way I get random numbers but there are several numbers in that array wich are shown twice or even more times, how can I change this program so it doesn't use the same number twice?

Can anyone please help me out?

Thanks in advance!
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 4:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC