les stacks se sauvegardent dans solution
This commit is contained in:
21
srcs/print.c
21
srcs/print.c
@@ -1,11 +1,26 @@
|
||||
|
||||
#include "pushswap.h"
|
||||
|
||||
void fill_solution(t_stack **a, t_stack **b, t_list **solution, char *sp)
|
||||
void fill_solution(t_stack *a, t_stack *b, t_list **solution, char *sp)
|
||||
{
|
||||
(void)a;
|
||||
char *stack;
|
||||
|
||||
(void)b;
|
||||
ft_lstadd_back(solution, ft_lstnew(sp));
|
||||
stack = ft_strdup(sp);
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" a"));
|
||||
while(a)
|
||||
{
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||
stack = ft_strjoinfree(stack, ft_itoa(a->n));
|
||||
a = a->next;
|
||||
}
|
||||
while(b)
|
||||
{
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||
stack = ft_strjoinfree(stack, ft_itoa(a->n));
|
||||
b = b->next;
|
||||
}
|
||||
ft_lstadd_back(solution, ft_lstnew(stack));
|
||||
}
|
||||
|
||||
void print_stack(t_stack *stack, char c)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "pushswap.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
void is_valid(int ac, char **av)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ t_list *sa(t_stack **stack, t_list **solution)
|
||||
tmp = a->n;
|
||||
a->n = a->next->n;
|
||||
a->next->n = tmp;
|
||||
fill_solution(stack, NULL, solution, ft_strdup("sa"));
|
||||
fill_solution(*stack, NULL, solution, ft_strdup("sa"));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user