Return to Snippet

Revision: 16936
at August 19, 2009 00:27 by mustam


Initial Code
#include <stdio.h>
#include <stdlib.h>

#define USAGE "Usage: %s NUMBER SEED\n"

int main(int argc, char ** argv)
{
    int i, n, seed;

    if(argc!=3){
        fprintf(stderr, USAGE, argv[0]);
        exit(0);
    }
    n=atoi(argv[1]);
    seed=atoi(argv[2]);
    srand(seed);
    for(i=0; i<n; i++) printf("%.3lf ", (double)rand()/1024);

    return 0;
}

Initial URL

                                

Initial Description
e.g.
<pre>
$ ./a.out 4 0
1762001.350586 827080.943359 1642278.102539 1674450.112305
</pre>

Initial Title
Generate random numbers

Initial Tags

                                

Initial Language
C