Files
42_INT_06_pushwap/srcs/print.c
2021-06-14 12:32:06 +02:00

47 lines
821 B
C

#include "pushswap.h"
void fill_solution(t_stack *a, t_stack *b, t_list **solution, char *sp)
{
char *stack;
(void)b;
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)
{
ft_printf(" %c | ", c);
while (stack)
{
ft_printf("%i", stack->n);
stack = stack->next;
if (stack)
ft_putstr(" ");
}
ft_putchar('\n');
}
void print_result(t_list *result)
{
while (result)
{
ft_printf("%s\n", result->content);
result = result->next;
}
}