예제 #1
0
void	sort_stack(t_stack *a, t_stack *b)
{
	int		min_max[2];

	if (g_v_opt)
		print_stacks(a, b);
	check_bottom(a, b);
	while (!check_top(a, b) || !check_last_push(a, b) || !empty(b))
	{
		if (get_min_max(a, min_max, min_max + 1) == 1)
			rot_to_min(a, b, min_max, 0);
		else
			rot_to_min(a, b, min_max, 1);
	}
}
예제 #2
0
void	search_min(t_e *e)
{
	t_list_cir	*tmp;
	t_list_cir	*tmp_min;
	int			i;

	e->rot = 0;
	i = 0;
	tmp = e->l_a->next;
	tmp_min = tmp;
	while (tmp != e->l_a)
	{
		if (tmp->n < tmp_min->n)
		{
			tmp_min = tmp;
			e->rot = i;
		}
		tmp = tmp->next;
		i++;
	}
	e->rev_rot = e->size_l - e->rot;
	rot_to_min(e);
}