Example #1
0
int			ft_filling(t_inv *move, int posi, char (*tab)[SIZE],
					char (*end)[SIZE])
{
	if (ft_backtrack(move, posi, tab, end) == 1)
	{
		ft_reboot(LTR, SIZE, tab);
		--LTR;
		if (posi < (SIZE * SIZE - 1))
			return (ft_filling(move, ++posi, tab, end));
		else if (ft_onlyp(SIZE, end) == 1 && LTR + 1 == 'A')
		{
			++SIZE;
			return (ft_fillit(move));
		}
	}
	else
	{
		ft_replacend(SIZE, tab, end);
		if (posi < (SIZE * SIZE - 1))
		{
			ft_reboot(LTR, SIZE, tab);
			return (ft_filling(move, ++posi, tab, end));
		}
	}
	--LTR;
	ft_reboot(++LTR + 1, SIZE, tab);
	--T;
	return (1);
}
Example #2
0
char		*ft_strnstr(const char *s1, const char *s2, size_t n)
{
	size_t		i;
	size_t		j;
	char		*dst;

	i = -1;
	j = 0;
	dst = NULL;
	if (!*s2)
		return ((char *)s1);
	while (s1[++i] && s2[j] && i < n)
	{
		if (s1[i] == s2[j] && j == 0)
			dst = (char *)&s1[i];
		if (s1[i] == s2[j])
			j++;
		else if (j)
			ft_reboot(i - j, 0, &i, &j);
	}
	if (s2[j] == '\0')
		return (dst);
	return (NULL);
}