Rev 2143 | Details | Compare with Previous | 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 | { |
||
8518 | bpr | 9 | int j; |
10 | for (j = 0; j < i; j++) |
||
11 | if (nbs[j] == n) |
||
12 | return 1; |
||
13 | return 0; |
||
2143 | bpr | 14 | } |
15 | |||
16 | void generate() |
||
17 | { |
||
8518 | bpr | 18 | int i; |
19 | int res; |
||
2143 | bpr | 20 | |
8518 | bpr | 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]); |
||
2143 | bpr | 46 | } |
47 | |||
48 | int main(int argc, char ** argv) |
||
49 | { |
||
8518 | bpr | 50 | int i, nb; |
2143 | bpr | 51 | |
8518 | bpr | 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 | } |
||
2143 | bpr | 57 | |
8518 | bpr | 58 | srand(getpid()); |
59 | nb = atoi(argv[1]); |
||
60 | for (i = 0 ; i < nb; i++) |
||
61 | generate(); |
||
62 | return 0; |
||
2143 | bpr | 63 | } |