|
Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://mavr.sao.ru/hq/sts/linux/book/c_marshall/section2_22_26.html
Дата изменения: Unknown Дата индексирования: Fri Dec 28 19:40:17 2007 Кодировка: Поисковые слова: sun |
/* random.c - simple example of setting random number seeds with time */
/* c89 random.c -o random */
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
main()
{ int i;
time_t t1;
(void) time(&t1);
srand48((long) t1); /* use time in seconds to set seed */
printf("5 random numbers (Seed = %d):\n",(int) t1);
for (i=0;i<5;++i)
printf("%d ", lrand48());
printf("\n\n"); /* flush print buffer */
/* lrand48() returns non-negative long integers
uniformly distributed over the interval (0, ~2**31)
*/
}