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
|
#include <unistd.h>
void change_to_max(int x[4], int left, int right)
{
int i;
i = 0;
while (i < 4)
{
if (left == 1)
x[0] = 4;
else if (right == 1)
x[3] = 4;
else if (i >= (left - 1) && i <= (4 - right))
x[i] = 4;
i++;
}
}
void ft_putchar(char c)
{
write(1, &c ,1);
}
int main(void)
{
int matrix[4][4] = {{0}};
int str[16] = {3, 3, 1, 2, 1, 2, 2, 3, 2, 3, 2, 1, 2, 1, 2, 3};
int a;
int e;
int g;
a = 0;
e = 12;
g = 8;
while (a < 4)
{
change_to_max(matrix[a], str[g], str[e]);
g++;
e++;
a++;
}
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++;
}
int matrix2[4][4] = {{0}};
}
|