les stacks se sauvegardent dans solution
This commit is contained in:
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
Binary file not shown.
BIN
builds/swap.o
BIN
builds/swap.o
Binary file not shown.
@@ -33,7 +33,7 @@ t_list *sort_algo(t_stack *stack);
|
|||||||
/*
|
/*
|
||||||
** print.c
|
** print.c
|
||||||
*/
|
*/
|
||||||
void fill_solution(t_stack **a, t_stack **b, t_list **lst, char *c);
|
void fill_solution(t_stack *a, t_stack *b, t_list **lst, char *c);
|
||||||
void print_stack(t_stack *stack, char c);
|
void print_stack(t_stack *stack, char c);
|
||||||
void print_result(t_list *lst);
|
void print_result(t_list *lst);
|
||||||
|
|
||||||
|
|||||||
21
srcs/print.c
21
srcs/print.c
@@ -1,11 +1,26 @@
|
|||||||
|
|
||||||
#include "pushswap.h"
|
#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;
|
(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)
|
void print_stack(t_stack *stack, char c)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "pushswap.h"
|
#include "pushswap.h"
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
void is_valid(int ac, char **av)
|
void is_valid(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ t_list *sa(t_stack **stack, t_list **solution)
|
|||||||
tmp = a->n;
|
tmp = a->n;
|
||||||
a->n = a->next->n;
|
a->n = a->next->n;
|
||||||
a->next->n = tmp;
|
a->next->n = tmp;
|
||||||
fill_solution(stack, NULL, solution, ft_strdup("sa"));
|
fill_solution(*stack, NULL, solution, ft_strdup("sa"));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user