-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpretty_table.c
More file actions
55 lines (48 loc) · 999 Bytes
/
pretty_table.c
File metadata and controls
55 lines (48 loc) · 999 Bytes
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
#include <stdio.h> /* printf, scanf, puts */
#include <stdlib.h> /* realloc, free, exit, NULL */
#ifndef N
#define N 8
#endif
void print_ascii_table()
{
for (int i = 0; i < 256; i++)
printf("%c -> %d\n\n", i, i);
}
int main()
{
int line_size = 0;
line_size = printf(" ");
for (int i = 1; i <= N; i++)
{
line_size += printf(" %4d ", i);
}
line_size += printf("\n");
putchar(201);
for (int i = 1; i < line_size - 1; i++)
{
if ((i + 1) % 6 == 0)
putchar(203);
else
putchar(205);
}
putchar(187);
printf("\n");
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
printf("%4d %c", j * i, 186);
}
printf("\n");
}
putchar(200);
for (int i = 1; i < line_size - 1; i++)
{
if ((i + 1) % 6 == 0)
putchar(202);
else
putchar(205);
}
putchar(188);
printf("\n");
}