-
Notifications
You must be signed in to change notification settings - Fork 0
/
g03.c
158 lines (143 loc) · 2.42 KB
/
g03.c
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SLEN 10000
static char S[SLEN + 1];
static void test00(void)
{
printf("abCDABCdaBcda\n");
}
static void test01(void)
{
printf("abcdefAbCdEf\n");
}
static void test02(void)
{
printf("aaaaaAaaaaaAaaaaaAabaaaAaaaaaAaaaaaA\n");
}
static void test03(void)
{
int n = SLEN;
int i;
for (i = 0; i < n; i++)
S[i] = 'A';
S[n] = '\0';
printf("%s\n", S);
}
static void test04(void)
{
int n = SLEN;
int i;
for (i = 0; i * 2 < n; i++)
S[i] = 'B';
for (; i < n; i++)
S[i] = 'b';
S[n] = '\0';
printf("%s\n", S);
}
static void test05(void)
{
int n = SLEN;
int i;
for (i = 0; i < n; i++)
S[i] = (i & 1) ? 'B' : 'b';
S[n] = '\0';
printf("%s\n", S);
}
static void test06(void)
{
int n = SLEN;
int i;
for (i = 0; i < n; i++)
S[i] = (i & 1) ? 'a' + i % 26 : 'A' + i % 26;
S[n] = '\0';
printf("%s\n", S);
}
static void test07(void)
{
int n = SLEN;
int i;
for (i = 0; i < n; i++)
S[i] = (i & 1) ? 'a' + (i * 19 % 26) : 'A' + (i * 19 % 26);
S[n] = '\0';
printf("%s\n", S);
}
static void test08(void)
{
int n = SLEN;
int i;
srand(8);
for (i = 0; i < n; i++)
S[i] = (rand() & 1) ? 'a' + rand() % 26 : 'A' + rand() % 26;
S[n] = '\0';
printf("%s\n", S);
}
static void test09(void)
{
int n = SLEN;
int i;
srand(9);
for (i = 0; i < n; i++)
S[i] = (rand() & 1) ? 'z' : 'Z';
S[n] = '\0';
printf("%s\n", S);
}
static void test10(void)
{
int n = SLEN;
int i;
char r[] = "hxuwyvHXUWYV";
char c = strlen(r);
srand(10);
for (i = 0; i < n; i++)
S[i] = r[rand() % c];
S[n] = '\0';
printf("%s\n", S);
}
static void test11(void)
{
int n = SLEN;
int i;
char r[] = "hxuwyv";
char c = strlen(r);
srand(10);
for (i = 0; i * 2 < n; i++)
S[i] = r[rand() % c];
for (; i < n; i++)
S[i] = toupper(r[rand() % c]);
S[n] = '\0';
printf("%s\n", S);
}
int main(int argc, char *argv[])
{
if (argc != 2)
return 1;
else if (atoi(argv[1]) == 0)
test00();
else if (atoi(argv[1]) == 1)
test01();
else if (atoi(argv[1]) == 2)
test02();
else if (atoi(argv[1]) == 3)
test03();
else if (atoi(argv[1]) == 4)
test04();
else if (atoi(argv[1]) == 5)
test05();
else if (atoi(argv[1]) == 6)
test06();
else if (atoi(argv[1]) == 7)
test07();
else if (atoi(argv[1]) == 8)
test08();
else if (atoi(argv[1]) == 9)
test09();
else if (atoi(argv[1]) == 10)
test10();
else if (atoi(argv[1]) == 11)
test11();
else
return 1;
return 0;
}