/* rand.c by Michael Thorpe 1999-02-14 */ #include #include #include #include #include int main(int argc,char **argv) { int i; if(argc != 1 && !(argc==2 && isdigit(argv[1][0]) && argv[1][0] != '0')) { printf("usage: %s [<#>]\n",argv[0]); return(1); } srand((int)time(0)+(int)getpid()); i=rand(); if(argc==2) i%=atol(argv[1]); printf("%d\n",i); return(0); }