find start and end fonctionne

This commit is contained in:
Hugo LAMY
2019-04-14 22:10:35 +02:00
parent 116ecdda43
commit 4ad02074b6
2 changed files with 28 additions and 7 deletions

Binary file not shown.

View File

@@ -6,28 +6,49 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
/* Updated: 2019/04/14 19:11:50 by hulamy ### ########.fr */
/* Updated: 2019/04/14 22:03:19 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/fillit.h"
#include <stdio.h>
int find_start_and_end(char *square)
void find_start_and_end(char **square, int *x1, int *x2, int *y1, int *y2)
{
int i;
i = 4;
while (*x1 < 4 && i == 4 && !(i = 0) && square[++(*x1)][0] != '#')
while (i < 4 && square[*x1][i] != '#')
i++;
i = 4;
while (*y1 < 4 && i == 4 && !(i = 0) && square[0][++(*y1)] != '#')
while (i < 4 && square[i][*y1] != '#')
i++;
i = -1;
while (++i < 4)
printf("%c",square[0] + i);
return (i);
while (*x2 >= 0 && i == -1 && (i = 3) && square[--(*x2)][3] != '#')
while (i >= 0 && square[*x2][i] != '#')
i--;
i = -1;
while (*y2 >= 0 && i == -1 && (i = 3) && square[3][--(*y2)] != '#')
while (i >= 0 && square[i][*y2] != '#')
i--;
}
void reduce_tetraminos(char **square, t_fillist *list)
{
int start;
int x1;
int x2;
int y1;
int y2;
start = find_start_and_end(square[1]);
x1 = -1;
y1 = -1;
x2 = 4;
y2 = 4;
find_start_and_end(square, &x1, &x2, &y1, &y2);
printf("de [%d,%d] a [%d,%d]\n",x1, y1, x2, y2);
(void)list;
}