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
|
#include "logo.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#define MAX_LOGOS 2
const char **logo(int index) {
static const char *logo0[] = {
" _____________",
" / \\",
" | ☆ ☆ ☆ |",
" | ☆ ☭ ☆ |",
" | ☆ ☆ ☆ |",
" \\_____________/",
" Рабочие мира, объединяйтесь!",
NULL
};
static const char *logo1[] = {
" ╔═══════════════════╗",
" ║ ║",
" ║ ☭ C C C P ☭ ║",
" ║ ║",
" ╚═══════════════════╝",
" Власть — Советам!",
NULL
};
if (index < 0 || index >= MAX_LOGOS) return NULL;
switch (index) {
case 0:
return logo0;
case 1:
return logo1;
default:
return NULL;
}
}
int get_line_length(const char **line) {
size_t length = 0;
size_t max_length = 0;
if (line == NULL) return -1;
for (int i = 0; line[i] != NULL; i++) {
length = strlen(line[i]);
if (length > max_length) {
max_length = length;
}
}
return max_length;
}
void print_logo(void) {
int length = 0;
for (int i = 0; i < MAX_LOGOS; i++) {
const char **lines = logo(i);
if (lines == NULL) continue;
length = get_line_length(lines);
for (int j = 0; lines[j] != NULL ; j++) {
printf("%s\n", lines[j]);
}
printf("%d\n", length);
}
}
|