push_swap/srcs/ps_rot.c
Tanguy MAZE 26f2acfcad hewow owo
added header, libft and all basic interactions with stack
2019-02-21 16:49:39 +01:00

37 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ps_rot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/21 16:07:55 by tmaze #+# #+# */
/* Updated: 2019/02/21 16:26:22 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ps_rot(t_stack **s)
{
t_stack *tmp;
t_stack *ind;
if (*s != NULL && ps_stksize(*s) > 2)
{
tmp = ps_stkpop(s);
ind = *s;
while (ind->next != NULL)
ind = ind->next;
ind->next = tmp;
}
else if (*s != NULL && ps_stksize(*s) == 2)
ps_swap(s);
}
void ps_rrot(t_stack **a, t_stack **b)
{
ps_rot(a);
ps_rot(b);
}