functions standardisees, annotees et readme en cours decriture

This commit is contained in:
hugogogo
2021-06-14 21:40:05 +02:00
parent 7a0f44c676
commit 5050e05816
17 changed files with 222 additions and 128 deletions

View File

@@ -1,19 +1,19 @@
#include "pushswap.h"
#include "push_swap.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"));
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;
}
stack = ft_strjoinfree(stack, ft_strdup("!b:"));
while(b)
{
stack = ft_strjoinfree(stack, ft_strdup(" "));
@@ -23,24 +23,21 @@ void fill_solution(t_stack *a, t_stack *b, t_list **solution, char *sp)
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)
void print_result(t_list *result, int flag)
{
char **part;
if (!flag)
result = result->next;
while (result)
{
ft_printf("%s\n", result->content);
part = ft_split(result->content, '!');
ft_printf("%s\n", part[0]);
if (flag)
{
ft_printf(" %s\n", part[1]);
ft_printf(" %s\n", part[2]);
}
result = result->next;
}
}