Random number generator

Patrick J. Fay pfay@acl.lanl.gov
Wed Jan 7 22:33:00 GMT 1998


Try:
PREINSTALLED /pfay/memory 262 > cat tst.c
#include <stdlib.h>
#include <math.h>
int rand100()
{
   double rmax=100.0/RAND_MAX;
   return((int)(rmax*(rand())));
}
int main()
{
   int i;

   for(i=0;i<10;i++)
   {
           printf("rand100=%d\n",rand100());
   }
   return 0;
}
PREINSTALLED /pfay/memory 263 > !gc
gcc tst.c -o tstc
PREINSTALLED /pfay/memory 264 > !./t
./tstc
rand100=51
rand100=17
rand100=30
rand100=53
rand100=94
rand100=17
rand100=70
rand100=22
rand100=49
rand100=12 

Patrick Fay, Ph.D., Intel Corp.            email:   pfay@co.intel.com
Los Alamos National Lab                    wk:         (505) 665-9141
CTI M.S. B296                              fax:        (505) 667-5921
Los Alamos NM 87545    ASCI-RED http://www.acl.lanl.gov/~pfay/teraflop

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list