Normed
This commit is contained in:
parent
e5c56950ef
commit
38eff0354b
|
@ -6,11 +6,11 @@
|
|||
/* By: smatthes <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/25 19:41:44 by smatthes #+# #+# */
|
||||
/* Updated: 2023/03/25 22:52:55 by smatthes ### ########.fr */
|
||||
/* Updated: 2023/03/26 06:13:02 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include<unistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int str_len(char *str)
|
||||
{
|
||||
|
@ -22,29 +22,29 @@ int str_len(char *str)
|
|||
return (i);
|
||||
}
|
||||
|
||||
void put_error()
|
||||
void put_error(void)
|
||||
{
|
||||
write(1,"Error\n",6);
|
||||
write(1, "Error\n", 6);
|
||||
}
|
||||
|
||||
|
||||
int *find_position(int **board, int n, int *pos)
|
||||
int *find_position(int **board, int n, int *pos)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = -1;
|
||||
j = -1;
|
||||
while(++i < n)
|
||||
while (++i < n)
|
||||
{
|
||||
while(++j < n)
|
||||
if(board[i][j] == 0)
|
||||
while (++j < n)
|
||||
{
|
||||
if (board[i][j] == 0)
|
||||
{
|
||||
pos[0] = i;
|
||||
pos[1] = j;
|
||||
return pos;
|
||||
return (pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: smatthes <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/25 18:58:21 by smatthes #+# #+# */
|
||||
/* Updated: 2023/03/25 23:29:41 by smatthes ### ########.fr */
|
||||
/* Updated: 2023/03/26 06:57:31 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -63,14 +63,13 @@ void atoi_arr(char **argv, int *borders, int n)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int check_opposite_sum(int *borders, int n)
|
||||
int check_opposite_sum(int *borders, int n)
|
||||
{
|
||||
int i;
|
||||
int val;
|
||||
int opp_val;
|
||||
int val;
|
||||
int opp_val;
|
||||
|
||||
i = 0;
|
||||
i = 0;
|
||||
while (i < 3 * n)
|
||||
{
|
||||
val = borders[1];
|
||||
|
@ -79,7 +78,7 @@ int check_opposite_sum(int *borders, int n)
|
|||
{
|
||||
return (0);
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
if (i == n)
|
||||
i = 2 * n;
|
||||
}
|
||||
|
|
|
@ -6,33 +6,32 @@
|
|||
/* By: smatthes <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/25 19:45:42 by smatthes #+# #+# */
|
||||
/* Updated: 2023/03/25 22:41:35 by smatthes ### ########.fr */
|
||||
/* Updated: 2023/03/26 06:58:14 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
# include<stdlib.h>
|
||||
# include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int **allo_mem(int **board, int n)
|
||||
int **allo_mem(int **board, int n)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
board = malloc(n * 8);
|
||||
i = -1;
|
||||
|
||||
while(++i < n)
|
||||
while (++i < n)
|
||||
{
|
||||
board[i] = malloc(4);
|
||||
}
|
||||
return board;
|
||||
return (board);
|
||||
}
|
||||
|
||||
void free_mem(int *borders, int **board, int n)
|
||||
void free_mem(int *borders, int **board, int n)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
i = -1;
|
||||
while(++i < n)
|
||||
i = -1;
|
||||
while (++i < n)
|
||||
{
|
||||
free(board[i]);
|
||||
}
|
||||
|
|
45
ex00/main.c
45
ex00/main.c
|
@ -1,31 +1,39 @@
|
|||
# include<unistd.h>
|
||||
# include<stdio.h>
|
||||
# include<stdlib.h>
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/26 06:13:07 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/26 06:58:29 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int **allo_mem(int **board, int n);
|
||||
void free_mem(int *borders, int **board, int n);
|
||||
int handle_input(int argc, char **argv, int *borders, int n);
|
||||
void put_error();
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int **allo_mem(int **board, int n);
|
||||
void free_mem(int *borders, int **board, int n);
|
||||
int handle_input(int argc, char **argv, int *borders, int n);
|
||||
void put_error(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int n;
|
||||
int *borders;
|
||||
int **board;
|
||||
int n;
|
||||
int *borders;
|
||||
int **board;
|
||||
|
||||
n = 4;
|
||||
|
||||
borders = malloc(n * 4 * 4);
|
||||
board = allo_mem(board, n);
|
||||
// handle sum of opposite inputs
|
||||
board = allo_mem(board, n);
|
||||
// handle sum of opposite inputs
|
||||
if (handle_input(argc, argv, borders, n) == 0)
|
||||
{
|
||||
put_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (backtrack(borders, board, n) == 0)
|
||||
{
|
||||
|
@ -35,8 +43,7 @@ int main(int argc, char **argv)
|
|||
|
||||
print_stuff
|
||||
*/
|
||||
free_mem(borders, board, n);
|
||||
free_mem(borders, board, n);
|
||||
return (0);
|
||||
}
|
||||
|
||||
// to do get position
|
||||
// TODO: get position
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: akarami <akarami@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/25 17:15:08 by akarami #+# #+# */
|
||||
/* Updated: 2023/03/25 18:15:52 by akarami ### ########.fr */
|
||||
/* Updated: 2023/03/26 06:11:37 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -21,9 +21,9 @@ void ft_print_arrays(int arr_matrix, int size)
|
|||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
|
||||
x = 1;
|
||||
while(x <= size)
|
||||
while (x <= size)
|
||||
{
|
||||
y = 1;
|
||||
while (y <= size)
|
||||
|
@ -39,10 +39,10 @@ void ft_print_arrays(int arr_matrix, int size)
|
|||
}
|
||||
}
|
||||
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int arr_matrix;
|
||||
int size;
|
||||
int arr_matrix;
|
||||
int size;
|
||||
|
||||
ft_print_arrays(arr_matrix, size);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue