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
|
#include <unistd.h>
void change_to_4(int *y)
{
*y = 4;
}
void change_to_max_y(int z[4][4], int a, int b)
{
int x;
x = 0;
while (x < 4)
{
int y;
y = 0;
while (y < 4)
{
if (y >= (a - 1) && y <= (4 - b))
change_to_4(&z[y][x]);
y++;
}
x++;
}
}
void ft_putchar(char c)
{
write(1, &c ,1);
}
int main(void)
{
int str[16] = {3, 3, 1, 2, 1, 2, 2, 3, 2, 3, 2, 1, 2, 1, 2, 3};
int matrix[4][4] = {{0}};
int a;
int b;
a = 0;
b = 4;
while (a < 4 && b < 8)
{
change_to_max_y(matrix, str[a], str[b]);
a++;
b++;
}
int i;
int j;
i = 0;
while (i <= 3)
{
j = 0;
while (j <= 3)
{
ft_putchar(matrix[i][j] + '0');
j++;
}
ft_putchar(0x0a);
i++;
}
}
|