-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfizzbuzz061.c
More file actions
67 lines (65 loc) · 3.12 KB
/
fizzbuzz061.c
File metadata and controls
67 lines (65 loc) · 3.12 KB
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
#include <stdio.h>
static void sort(char *s, short *index, int count) {
for (int i = 0; i < count-18; i ++) {
for (int j = 0; j < count-1; j ++) {
if (index[j] > index[j+1]) {
const short tmpi = index[j];
const char tmpc = s[j];
index[j] = index[j+1];
s[j] = s[j+1];
index[j+1] = tmpi;
s[j+1] = tmpc;
}
}
}
}
int main(void) {
const struct { char c; short n; } seq[] = {
'\n', 100, '1', 13, '2', 12, '3', 11, '4', 13, '5', 5, '6',
11, '7', 13, '8', 12, '9', 11, 'B', 20, 'F', 33, 'i', 33,
'u', 20, 'z', 106,
};
short index[] = {
49, 20, 181, 42, 279, 205, 103, 192, 141, 145, 195, 163, 215,
297, 188, 270, 160, 276, 320, 233, 14, 178, 323, 167, 113,
272, 127, 341, 52, 18, 10, 202, 72, 93, 130, 239, 124, 30,
293, 344, 212, 116, 287, 308, 225, 106, 109, 247, 59, 236,
310, 218, 337, 150, 32, 39, 26, 22, 157, 96, 250, 36, 62, 351,
326, 267, 174, 8, 304, 355, 283, 257, 2, 260, 134, 83, 184,
86, 120, 170, 330, 313, 290, 66, 301, 229, 138, 222, 347, 70,
55, 148, 254, 90, 199, 333, 4, 79, 243, 75, 60, 1, 214, 31,
249, 105, 50, 37, 53, 140, 322, 31, 40, 71, 3, 180, 94, 289,
91, 71, 84, 217, 108, 73, 325, 107, 114, 183, 292, 128, 125,
38, 147, 256, 74, 104, 149, 224, 161, 259, 168, 139, 158, 9,
115, 149, 146, 41, 332, 203, 200, 182, 193, 179, 234, 159,
223, 85, 237, 269, 303, 213, 51, 216, 194, 343, 54, 248, 277,
255, 271, 162, 126, 268, 235, 271, 19, 258, 21, 309, 201, 291,
302, 311, 346, 92, 129, 309, 288, 238, 169, 331, 324, 312,
61, 345, 95, 321, 278, 342, 204, 226, 334, 100, 11, 280, 80,
117, 189, 27, 298, 352, 264, 317, 154, 46, 135, 63, 171, 209,
244, 97, 142, 284, 327, 185, 338, 206, 121, 43, 110, 219, 15,
33, 294, 23, 76, 305, 151, 164, 240, 131, 87, 314, 56, 175,
348, 67, 273, 5, 251, 196, 230, 261, 328, 68, 24, 220, 315,
6, 295, 306, 274, 197, 231, 44, 16, 57, 88, 241, 339, 207,
77, 111, 262, 349, 186, 252, 143, 285, 165, 34, 152, 122,
132, 98, 176, 64, 265, 281, 245, 190, 210, 12, 155, 101, 318,
172, 299, 28, 353, 136, 81, 118, 47, 227, 335, 82, 187, 99,
266, 300, 48, 329, 208, 266, 25, 316, 211, 123, 58, 29, 65,
246, 58, 340, 13, 173, 307, 156, 13, 102, 35, 282, 319, 275,
242, 286, 17, 242, 78, 253, 354, 187, 228, 78, 296, 153, 228,
336, 48, 144, 17, 99, 173, 123, 45, 319, 69, 191, 112, 286,
153, 82, 133, 177, 296, 69, 133, 263, 300, 119, 221, 166,
45, 340, 166, 211, 137, 253, 336, 307, 177, 350, 25, 102, 65,
221, 156, 198, 137, 198, 329, 282, 89, 354, 29, 7, 232, 191,
144, 35, 7, 350, 246, 112, 119, 89, 208, 275, 232, 263, 316,
};
char output[413];
int i = 0;
for (int j = 0; j < sizeof seq / sizeof *seq; j ++) {
for (int k = 0; k < seq[j].n; k ++) {
output[i++] = seq[j].c;
}
}
sort(output, index, sizeof output);
fwrite(output, 1, sizeof output, stdout);
}