source: trunk/instant_messenger/bkp/socket/BKP_20071105/BKP_20071026/BKP_20071019/BKP_20071018/BKP_20071009/BKP_20071008/BKP/BKP/rand.c @ 216

Revision 216, 576 bytes checked in by niltonneto, 17 years ago (diff)

Correções do módulo instant_messenger.
Ver WiKi? em: http://www.expressolivre.org/dev/wiki/messenger

Line 
1#include <stdio.h>
2#include <stdlib.h>
3/*
4
5#define MAX 10000
6
7int main(void)
8{
9        int i = (int)NULL;
10        int j =i;
11        long int vet[MAX];
12
13        for ( i = 0; i < MAX; ++i )
14        {
15                vet[i] = rand();
16                for ( j = 0; j < i; ++j )
17                        if ( vet[i] == vet[j] )
18                                printf("[%d]%d - [%d]%d\n", i, vet[i], j, vet[j]);
19        }
20        printf("rand_max: %d\n", RAND_MAX);
21        printf("time: %d\n", time(NULL));
22        printf("rand: %d\n", rand(1));
23}
24*/
25
26main(int ac, char **av)
27{
28        double x;
29        unsigned seed;
30
31        if (ac > 0) {
32                sscanf(microtime,"%u", &seed);
33                srand(seed);
34        }
35
36        x = rand()/(RAND_MAX+1.0);
37
38        printf("%g\n",x);
39}
Note: See TracBrowser for help on using the repository browser.