Fix header file includes AND add write for each push swap functions

This commit is contained in:
David Gailleton
2025-12-12 11:40:02 +01:00
parent 1463f3e14a
commit 55363e0e6f
6 changed files with 55 additions and 19 deletions

View File

@@ -6,11 +6,12 @@
/* By: mteriier <mteriier@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/12/08 14:48:44 by mteriier #+# #+# */
/* Updated: 2025/12/08 19:40:49 by mteriier ### ########.fr */
/* Updated: 2025/12/12 11:38:52 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "../push_swap.h"
#include "push_swap.h"
#include <unistd.h>
void sa(t_stacks *stacks)
{
@@ -23,6 +24,7 @@ void sa(t_stacks *stacks)
stock = a->value;
a->value = a->next->value;
a->next->value = stock;
write(1, "sa\n", 3);
}
void sb(t_stacks *stacks)
@@ -36,10 +38,30 @@ void sb(t_stacks *stacks)
stock = b->value;
b->value = b->next->value;
b->next->value = stock;
write(1, "sb\n", 3);
}
void ss(t_stacks *stacks)
{
sa(stacks);
sb(stacks);
t_stack *b;
t_stack *a;
int stock;
if (!stacks)
return ;
if (stacks->b && stacks->b->next)
{
b = stacks->b;
stock = b->value;
b->value = b->next->value;
b->next->value = stock;
}
if (stacks->a && stacks->a->next)
{
a = stacks->a;
stock = a->value;
a->value = a->next->value;
a->next->value = stock;
}
write(1, "ss\n", 3);
}