diff options
| author | Matsuko Sano <msano@c1r17s9.42tokyo.jp> | 2022-08-22 17:30:07 +0900 |
|---|---|---|
| committer | Matsuko Sano <msano@c1r17s9.42tokyo.jp> | 2022-08-22 17:30:07 +0900 |
| commit | be31e6b7731a2f3142fbf29472ae1d71f82765fb (patch) | |
| tree | 53e48351cdefed0a60072e7a805e8736add02786 /rush/max_test.c | |
| parent | 43cbb3f685d5895bb1877f683060d7d2958d5966 (diff) | |
Diffstat (limited to 'rush/max_test.c')
| -rw-r--r-- | rush/max_test.c | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/rush/max_test.c b/rush/max_test.c new file mode 100644 index 0000000..057780d --- /dev/null +++ b/rush/max_test.c @@ -0,0 +1,129 @@ +#include <unistd.h> + +void change_to_max(int x[4], int l, int r) +{ + int i; + i = 0; + while (i < 4) + { + if (i >= (l - 1) && i <= (4 - r)) + x[i] = 4; + i++; + } +} + +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; + int c; + int d; + int e; + int f; + int g; + int h; + + a = 0; + b = 1; + c = 2; + d = 3; + e = 12; + f = 5; + h = 4; + + g = 8; + + // while (a < 4) + // { + // change_to_max(matrix[a], str[g], str[e]); + // g++; + // e++; + // a++; + // } + +// int x; +// int y; +// x = 0; +// y = 0; +{ + int x; + x = 0; + while (x < 4) + { + int y; + y = 0; + while (y < 4) + { + if (y >= (str[a] - 1) && y <= (4 - str[h])) + change_to_max2(&matrix[y][x]); + y++; + } + x++; + } +} + + +// while (b < 4) +// { +// if (b >= (d - 1) && b <= (4 - c)) +// change_to_max2(&matrix[b][0]); +// b++; +// } + +// while (c < 4) +// { +// if (c >= (b - 1) && c <= (4 - c)) +// change_to_max2(&matrix[c][0]); +// c++; +// } + +// while (a < 4) +// { +// if (d >= (c - 1) && d <= (4 - d)) +// change_to_max2(&matrix[a][0]); +// d++; +// } + + 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 x; + x = 0; + while (x < 4) + { + int y; + y = 0; + while (y < 4) + { + if (y >= (str[a] - 1) && y <= (4 - str[b])) + change_to_4(&matrix[y][x]); + y++; + a++; + b++; + } + x++; + } +}
\ No newline at end of file |
