View Single Post
Old 01-28-2004, 07:22 AM   #7 (permalink)
supafly
Psycho
 
supafly's Avatar
 
Location: Rotterdam
The rand command works!
Check out the source code:

#include <stdio.h>

#define MAX 100

int a[MAX];
int rand_seed=10;

/*Returns random number between 0 and 32767.*/

int rand()
{
rand_seed = rand_seed * 1103515245 +12345;
return (unsigned int)(rand_seed / 65536) % 32768;
}

int main()
{
int i,t,x,y;

/* fill array */
for (i=0; i < MAX; i++)
{
a[i]=rand();
printf("%d\n",a[i]);
}
return 0;
}

Comment:
#define MAX 100, the size of the array is 100.
int rand_seed=10, by changing the the value of the seed you will get an array with other random ganerated numbers.

Thank you all for helping me!
__________________
Thumbs up
supafly is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73