-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (71 loc) · 1.58 KB
/
Copy pathmain.cpp
File metadata and controls
85 lines (71 loc) · 1.58 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <string.h>
#include "farmsay.tab.h"
inline
void line(const char c, const int n) {
putc(' ', stdout);
for (int i = 0; i < n-2; i++) {
putc(c, stdout);
}
putc('\n', stdout);
}
void frame(const char f, const int b, const char * s) {
const int WIDTH = 24;
line(f, WIDTH);
const int l = strlen(s);
for (int i = 0; i < (l / (WIDTH-4)) + 1; i++) {
printf("%c %-20.20s %c\n", f, s + (i*(WIDTH-4)), f);
}
line(f, WIDTH);
for (int i = 0; i < b; i++) {
putc(' ', stdout);
}
fputs("|/\n", stdout);
}
void bison_say(const char * const s) {
const char * const BISON =
" .xxx###;=>\n"
":xxxx####> \n"
" L p \n"
;
fputs("\033[31m", stdout);
frame('*', 12, s);
puts(BISON);
fputs("\033[0m", stdout);
}
void snake_say(const char * const s) {
const char * const SNAKE =
" .~-\n"
" '. \n"
" :..;\n"
;
fputs("\033[32m", stdout);
frame(';', 7, s);
puts(SNAKE);
fputs("\033[0m", stdout);
}
void sheep_say(const char * const s) {
const char * const SHEEP =
" ____ o=\n"
",######[ \n"
" l l \n"
;
fputs("\033[33m", stdout);
frame('o', 10, s);
puts(SHEEP);
fputs("\033[0m", stdout);
}
void duck_say(const char * const s) {
const char * const DUCK =
" \\_0<\n"
" V_ \n"
;
fputs("\033[34m", stdout);
frame('X', 6, s);
puts(DUCK);
fputs("\033[0m", stdout);
}
signed main(int argc, char * * argv) {
yyparse();
return 0;
}