/*----------------------------------------------------------------------- Cube Susan L. Weller ----------------------------------------------------------------------- This program will generate a given number of points that lie inside a cube. The number of points is given on command line. -----------------------------------------------------------------------*/ #include #include #define MAX_INT 2147483647 main( argc, argv ) int argc; char *argv[]; { int n; double x, y, z; srandom( (int) time( (long *) 0 ) ); if ( argc != 2 ) { printf("Usage: cube \n"); exit(1); } n = atoi( argv[1] ); while ( n-- ) { x = 2.0 * (double) random() / MAX_INT - 1.0; y = 2.0 * (double) random() / MAX_INT - 1.0; z = 2.0 * (double) random() / MAX_INT - 1.0; printf ("%6d %6d %6d\n", (int) (100*x ), (int) ( 100*y ), (int) (100 * z) ); } }