blob: 6950adbcba34df33628c7c37e10b373cbcc5a4d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* Generate random test datas, best for explicit support test. */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int lev = 0, len = 0, minlen;
void
letter ()
{
char rl = (rand () % 2 ? 'a' : 'A');
int i, j = rand () % 5;
len += j;
for (i = 0; i < j; i++)
putchar (rl + rand () % 26);
}
void
number ()
{
int i, j = rand () % 5;
len += j;
switch (rand () % 16)
{
case 10:
putchar ('[');
break;
case 11:
putchar (']');
break;
case 12:
putchar ('{');
break;
case 13:
putchar ('}');
break;
case 14:
putchar ('(');
break;
case 15:
putchar (')');
break;
default:
for (i = 0; i < j; i++)
putchar ('0' + rand () % 6);
break;
}
}
void
gen ()
{
int f = 1;
while (f)
switch (rand () % 12)
{
case 0:
len += 2;
printf ("_R");
gen ();
printf ("_o");
break;
case 1:
len += 2;
printf ("_r");
gen ();
printf ("_o");
break;
case 2:
len += 2;
printf ("_L");
gen ();
printf ("_o");
break;
case 3:
len += 2;
printf ("_l");
gen ();
printf ("_o");
break;
case 4:
len++;
letter ();
letter ();
printf (" ");
break;
case 5:
number ();
break;
case 6:
len++;
printf (" ");
break;
default:
letter ();
if (len << lev > minlen)
f = 0;
break;
}
}
int
main (int argc, char **argv)
{
if (argv[1])
minlen = atoi (argv[1]);
else
minlen = 1;
srand ((int) (time) (NULL));
gen ();
printf ("\n");
}
|