Repeat « random « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » random » Repeat 

1. non-repeating random numbers    cboard.cprogramming.com

2. repeated random numbers    forums.devshed.com

I need to generate 10000+ random numbers to do a simulation. I use a random number generator that I downloaded from Internet. I use time(0) as seed. But the number will repeat about 20 times before a new number can be generated. What is the problem? I used the generate for a different program before and it worked fine. If it's ...

3. not getting non repeating random numbers many times    daniweb.com

#include "sys/types.h" #include "stdio.h" #define MAX 200 #define N 20 main() { int array[N],r; int n = 0; int count_check,count_gen ,i,j; for(j=0;j<10;j++,printf("\n")) { srand(j); for (count_gen=0;count_gen<=MAX;count_gen++) { r = rand()%N; for ( count_check = 0; count_check < n; count_check++ ) { if ( r == array[count_check] )break; }// end for count_check. if ( count_check == n ) array[n++] = r; }// ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.