ajout du script de comparaison
This commit is contained in:
@@ -39,11 +39,14 @@ void fill_solution(t_list *solution, char *sp)
|
||||
|
||||
void print_result(t_list *result, int flag)
|
||||
{
|
||||
int i;
|
||||
char **part;
|
||||
|
||||
i = -1;
|
||||
result = result->next->next;
|
||||
while (result)
|
||||
{
|
||||
i++;
|
||||
part = ft_split(result->content, '!');
|
||||
ft_printf("%s\n", part[0]);
|
||||
if (flag)
|
||||
@@ -57,4 +60,6 @@ void print_result(t_list *result, int flag)
|
||||
free(part[2]);
|
||||
free(part);
|
||||
}
|
||||
if (flag)
|
||||
ft_putnbrendl(i);
|
||||
}
|
||||
|
||||
15
srcs/push.c
15
srcs/push.c
@@ -5,13 +5,14 @@ void push(t_stack **dst, t_stack **src)
|
||||
t_stack *tmp1;
|
||||
t_stack *tmp2;
|
||||
|
||||
if (!((*src)->next))
|
||||
return ;
|
||||
tmp1 = *src;
|
||||
tmp2 = *dst;
|
||||
*src = (*src)->next;
|
||||
tmp1->next = tmp2;
|
||||
*dst = tmp1;
|
||||
if (*src)
|
||||
{
|
||||
tmp1 = *src;
|
||||
tmp2 = *dst;
|
||||
*src = (*src)->next;
|
||||
tmp1->next = tmp2;
|
||||
*dst = tmp1;
|
||||
}
|
||||
}
|
||||
|
||||
t_list *pa(t_stack **a, t_stack **b, t_list **solution)
|
||||
|
||||
@@ -47,10 +47,10 @@ t_list *launch_algo(t_stack **a, t_stack **b, int flag)
|
||||
ft_lstadd_back(&solution, ft_lstnew(b));
|
||||
if (flag)
|
||||
fill_solution(solution, "start");
|
||||
hugo_sort(a, b, solution);
|
||||
// hugo_sort(a, b, solution);
|
||||
bubble_sort(a, b, solution);
|
||||
return (solution);
|
||||
}
|
||||
// bubble_sort(&a, &b, solution);
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
|
||||
@@ -5,17 +5,18 @@ void reverse_rotate(t_stack **stack)
|
||||
t_stack *tmp;
|
||||
t_stack *before;
|
||||
|
||||
tmp = *stack;
|
||||
if (!tmp || !(tmp->next))
|
||||
return ;
|
||||
while (tmp->next)
|
||||
if (*stack && (*stack)->next)
|
||||
{
|
||||
before = tmp;
|
||||
tmp = tmp->next;
|
||||
tmp = *stack;
|
||||
while (tmp->next)
|
||||
{
|
||||
before = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->next = *stack;
|
||||
*stack = tmp;
|
||||
before->next = NULL;
|
||||
}
|
||||
tmp->next = *stack;
|
||||
*stack = tmp;
|
||||
before->next = NULL;
|
||||
}
|
||||
|
||||
t_list *rra(t_stack **a, t_list **lst)
|
||||
|
||||
@@ -5,15 +5,16 @@ void rotate(t_stack **stack)
|
||||
t_stack *tmp;
|
||||
t_stack *first;
|
||||
|
||||
first = *stack;
|
||||
tmp = *stack;
|
||||
if (!tmp || !(tmp->next))
|
||||
return ;
|
||||
*stack = (*stack)->next;
|
||||
while (tmp->next)
|
||||
tmp = tmp->next;
|
||||
tmp->next = first;
|
||||
first->next = NULL;
|
||||
if (*stack && (*stack)->next)
|
||||
{
|
||||
first = *stack;
|
||||
tmp = *stack;
|
||||
*stack = (*stack)->next;
|
||||
while (tmp->next)
|
||||
tmp = tmp->next;
|
||||
tmp->next = first;
|
||||
first->next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
t_list *ra(t_stack **a, t_list **lst)
|
||||
|
||||
13
srcs/swap.c
13
srcs/swap.c
@@ -4,12 +4,13 @@ void swap(t_stack **stack)
|
||||
{
|
||||
t_stack *tmp;
|
||||
|
||||
tmp = *stack;
|
||||
if (!(tmp->next))
|
||||
return ;
|
||||
*stack = (*stack)->next;
|
||||
tmp->next = (*stack)->next;
|
||||
(*stack)->next = tmp;
|
||||
if (*stack && (*stack)->next)
|
||||
{
|
||||
tmp = *stack;
|
||||
*stack = (*stack)->next;
|
||||
tmp->next = (*stack)->next;
|
||||
(*stack)->next = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
t_list *sa(t_stack **a, t_list **solution)
|
||||
|
||||
Reference in New Issue
Block a user