Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include <stdlib.h> |
---|
3 | /* |
---|
4 | |
---|
5 | #define MAX 10000 |
---|
6 | |
---|
7 | int 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 | |
---|
26 | main(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.