hi
i want to generate non repeated random numbers many times. for that i m using the following code.
#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;
}// end for count_gen.
for(i=0;i<N;i++)
printf("%d\n",array[i]);
}// end for j.
}// end of main.
<< moderator edit: added [code][/code] tags >>
it generates random numbers from 0 to 20 without repeating in an array. but it generates only once. next time in the for loop ( in j ) it gives the same pattern again , which i dont want. can some body please help me to get different pattern every time in the for loop ( for j ).