how to generate random numbers of the same at each time of execution of thm

dear friends

i am facing a problem that the random numbers generated at time of each exectuion of the program are not the same, i want to generate the same random numbers every time time i run the program. i need your help. i am giving the code in c++ if anybody can help in providing the solution so that i get the same random numbers at every run of the program. waiting for your help

wit regards

jaya shankar

#include<iostream.h>

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

#include<math.h>

class density

{

int s[150][150],parent[150][150],i,j,l,n,loop;

public:

void bd(void);

void css(void);

};

void density :: bd(void)

{

cout<<"ENTER THE POPULATION SIZE = ";

cin>>n;

cout<<"\nENTER THE NO.OF LOOPS = ";

cin>>loop;

for(i=0;i<n;i++)

for(j=0;j<80;j++)

{

s[j]=rand()%2;

cout><<"s:"<<s[j];

}

}

void density :: css(void)

{

int a,b;

float c;

for(i=0;i<n;i=i+2)

{

b=rand()%100;

cout><<"random b="<<b;

}

}

main()

{

density d;

d.bd();

d.css();

}

>

[1332 byte] By [jayashankar] at [2007-9-27 1:56:33]
# 1
Do not randomize the random number interface when you start your application. When the random number interface is not randomized when starting you get the same sequence of numbers each and every time you use it.
morgalr at 2007-7-4 20:36:42 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 2
Give the Random class a seed and the sequence will always be the same.Random randy = new Random( 4455 );
beggarstune at 2007-7-4 20:36:42 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 3
Make that the same seed each and every time.
morgalr at 2007-7-4 20:36:42 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...