Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2143 | bpr | 1 | #include <stdlib.h> |
2 | #include <stdio.h> |
||
3 | #include <unistd.h> |
||
4 | |||
5 | int nbs[6]; |
||
6 | |||
7 | int alreadythere(int n, int i) |
||
8 | { |
||
9 | int j; |
||
10 | for (j = 0; j < i; j++) |
||
11 | if (nbs[j] == n) |
||
12 | return 1; |
||
13 | return 0; |
||
14 | } |
||
15 | |||
16 | void generate() |
||
17 | { |
||
18 | int i; |
||
19 | int res; |
||
20 | |||
21 | for (i = 0; i < 6; i++) |
||
22 | { |
||
23 | do |
||
24 | { |
||
25 | switch(res = rand() % 14) |
||
26 | { |
||
27 | case 0: |
||
28 | res = 100; |
||
29 | break; |
||
30 | case 11: |
||
31 | res = 75; |
||
32 | break; |
||
33 | case 12: |
||
34 | res = 50; |
||
35 | break; |
||
36 | case 13: |
||
37 | res = 25; |
||
38 | break; |
||
39 | default: |
||
40 | } |
||
41 | } |
||
42 | while (alreadythere(res, i)); |
||
43 | nbs[i] = res; |
||
44 | } |
||
45 | printf("%d %d %d %d %d %d %d\n", rand() % 900 + 100, nbs[0], nbs[1], nbs[2], nbs[3], nbs[4], nbs[5]); |
||
46 | } |
||
47 | |||
48 | int main(int argc, char ** argv) |
||
49 | { |
||
50 | int i, nb; |
||
51 | |||
52 | if (argc != 2) |
||
53 | { |
||
54 | printf("Wrong number of arguments. Specify the number of sets of data to generate.\n"); |
||
55 | return 1; |
||
56 | } |
||
57 | |||
58 | srand(getpid()); |
||
59 | nb = atoi(argv[1]); |
||
60 | for (i = 0 ; i < nb; i++) |
||
61 | generate(); |
||
62 | return 0; |
||
63 | } |