Exemple #1
0
void	ft_prepa_push(t_pile **a, t_pile **b, t_flag *f, char *cs)
{
	int		val;
	t_pile	**pile;

	pile = (cs[0] == 'a') ? a : b;
	val = (cs[1] == '+') ? ft_find_max(pile) : ft_find_min(pile);
	if (ft_pos_val(pile, val) <= (ft_length_pile(pile) + 1) / 2)
	{
		while ((*pile)->nb != val)
			(cs[0] == 'a') ? ft_rotatea(a, b, f) : ft_rotateb(a, b, f);
	}
	else
	{
		while ((*pile)->nb != val)
			(cs[0] == 'a') ? ft_reversea(a, b, f) : ft_reverseb(a, b, f);
	}
}
Exemple #2
0
void		ft_algo(t_info *info)
{
	int	min;

	if (SSIZEA == 1)
		return ;
	ft_sort_sa_test(info);
	ft_sort_reverse(info);
	while (!ft_sort_test_pa(info))
	{
		min = ft_find_min(SIPA, info);
		if (min < SSIZEA / 2)
			ft_while_rr(info, min);
		else
			ft_while_r(info, min);
		if (!ft_sort_test_pa(info))
			ft_push_b(SIPB, SIPA, info);
	}
	while (SSIZEB > 0)
		ft_push_a(SIPA, SIPB, info);
}