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 | |
| parent | 43cbb3f685d5895bb1877f683060d7d2958d5966 (diff) | |
| -rwxr-xr-x | rush/a.out | bin | 0 -> 8748 bytes | |||
| -rw-r--r-- | rush/max_search_3.c | 21 | ||||
| -rw-r--r-- | rush/max_search_x.c | 63 | ||||
| -rw-r--r-- | rush/max_search_x_trial.c | 69 | ||||
| -rw-r--r-- | rush/max_search_y.c | 69 | ||||
| -rw-r--r-- | rush/max_test.c | 129 | ||||
| -rw-r--r-- | rush/minus_str.c | 53 | ||||
| -rw-r--r-- | rush/sorry.c | 5 | ||||
| -rw-r--r-- | rush/test.c | 43 | ||||
| -rw-r--r-- | rush/testy.c | 73 |
10 files changed, 525 insertions, 0 deletions
diff --git a/rush/a.out b/rush/a.out Binary files differnew file mode 100755 index 0000000..43339b1 --- /dev/null +++ b/rush/a.out diff --git a/rush/max_search_3.c b/rush/max_search_3.c new file mode 100644 index 0000000..47ec2b9 --- /dev/null +++ b/rush/max_search_3.c @@ -0,0 +1,21 @@ +#include <unistd.h> +void max_search_3(int x[4], int left, int right) +{ + if (left - right == 0) + { + x[0] = 3; + x[3] = 3; + } + if (left == 2 && right == 3) + { + x[0] = 3; + x[2] = 3; + } + if (left == 3 && right == 2) + { + x[3] = 3; + x[1] = 3; + } + if + +}
\ No newline at end of file diff --git a/rush/max_search_x.c b/rush/max_search_x.c new file mode 100644 index 0000000..244fb2d --- /dev/null +++ b/rush/max_search_x.c @@ -0,0 +1,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}}; + +}
\ No newline at end of file diff --git a/rush/max_search_x_trial.c b/rush/max_search_x_trial.c new file mode 100644 index 0000000..84d51c2 --- /dev/null +++ b/rush/max_search_x_trial.c @@ -0,0 +1,69 @@ +#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 change_to_max2(int *y) +{ + + *y = 4; + +} + +void ft_putchar(char c) +{ + write(1, &c ,1); +} + +int main(void) +{ + int matrix[4][4] = {{0}}; + + // int a; + // a = 0; + // { + // change_to_max(matrix[a], 2, 2); + // a++; + // }` + + int b; + b = 0; + + int t; + int u; + + t = 2; + u = 2; + + while (b < 4) + { + if (b >= (t - 1) && b <= (4 - u)) + change_to_max2(&matrix[b][0]); + 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++; + } +}
\ No newline at end of file diff --git a/rush/max_search_y.c b/rush/max_search_y.c new file mode 100644 index 0000000..c3680a4 --- /dev/null +++ b/rush/max_search_y.c @@ -0,0 +1,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++; + } + +}
\ No newline at end of file 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 diff --git a/rush/minus_str.c b/rush/minus_str.c new file mode 100644 index 0000000..773d277 --- /dev/null +++ b/rush/minus_str.c @@ -0,0 +1,53 @@ +#include <unistd.h> + +void minus_str(int str[]) +{ + int i; + i = 0; + while (i < 16) + { + str[i] = str[i] - 1; + if(str[i] < 0) + { + str[i] = str[i] + 4; + } + else if(str[i] > 4) + { + str[i] = str[i] - 4; + } + i++; + } +} + +void ft_putchar(char c) +{ + write(1, &c ,1); +} + +void putstr(int str []) +{ + int i; + i = 0; + while (i < 16) + { + ft_putchar(str[i] + '0'); + i++; + } +} + +int main(void) +{ + int str[16] = {3, 3, 1, 2, 1, 2, 2, 3, 2, 3, 2, 1, 2, 1, 2, 3}; + + putstr(str); + ft_putchar('\n'); + + minus_str(str); + putstr(str); + ft_putchar('\n'); + + minus_str(str); + putstr(str); + ft_putchar('\n'); + +}
\ No newline at end of file diff --git a/rush/sorry.c b/rush/sorry.c new file mode 100644 index 0000000..b084cda --- /dev/null +++ b/rush/sorry.c @@ -0,0 +1,5 @@ +#include <unistd.h> +int main(int argc, char *argv[]) +{ + write(1, argv[1], 31); +} diff --git a/rush/test.c b/rush/test.c new file mode 100644 index 0000000..051d840 --- /dev/null +++ b/rush/test.c @@ -0,0 +1,43 @@ +// カスタム化されたヘッダーファイルを使用するため +// unistad.hにwrite関数が含まれているため、ヘッダーファイルを追加した +// テスト用にprintfを24及び40行目に配置、そのためstdio.hを追加。提出時は削除またはアウト +#include "ft_main.h" +#include <unistd.h> +#include <stdio.h> +// *char_to_int関数はChar型からInt型に変えるための自作関数 +// Charポインタ型およびIntポインタ型 +void char_to_int(char *str, int *box) +{ + int i; + int j; + + i = 0; + j = 0; + // 変数StrはArgvの先頭を指している。先頭からi文字後を添字[]でアクセスしている。 + while (str[j] != '\0') + { + // もし1から9までの文字の場合、BoxにChar型からIntに変換後に格納する。 + if ('0' <= str[j] && str[j] <= '9') + { + box[i] = str[j] - '0'; + // 提出時は削除またはコメントアウト + // printf("%d",box[i]); + i++; + } + j++; + } +} +// 返却値の型はInt型ですよ。関数名はMain。 +// 引数はInt型Argc(コマンドライン引数の数) +// 引数はCharダブルポインタ型のArgv(文字列配列型) +int main(int argc, char *argv[]) +{ + // Int型のBox_16を宣言[]内は要素の数を入力している + // Argv[1]はファイル名の後ろの空白の後ろの文字列(12345…) + int box_16[16]; + char_to_int(argv[1],box_16); + + // printf("\n%d",box_16[2]); + + return (0); +} diff --git a/rush/testy.c b/rush/testy.c new file mode 100644 index 0000000..8f3b8ab --- /dev/null +++ b/rush/testy.c @@ -0,0 +1,73 @@ +// void max_search_y(int m[4][4]) +// { +// int x; +// x = 0; + +// while (x < 4) +// { +// int y; +// y = 0; + +// while (y < 4) +// if (y >= (t - 1) && y <= (4 - u)) +// change_to_max2(&matrix[y][x]); +// y++; +// } +// x++; +// } +#include <unistd.h> +void change_to_4(int *y) +{ + + *y = 4; + +} + +void ft_putchar(char c) +{ + write(1, &c ,1); +} + +int main(void) +{ + int matrix[4][4] = {{0}}; + + int b; + b = 0; + + int t; + int u; + + t = 2; + u = 2; + + while (b < 4) + { + if (b >= (t - 1) && b <= (4 - u)) + change_to_4(&matrix[b][0]); + 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++; + } + + // while (b < 4) + // { + // if (b >= (t - 1) && b <= (4 - u)) + // change_to_max2(&matrix[b][1]); + // b++; + // } +}
\ No newline at end of file |
