mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
Fix header file includes AND add write for each push swap functions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user