42_push_swap/ft_p.c
2022-12-07 14:19:16 +01:00

45 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_p.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/09 16:38:34 by cchauvet #+# #+# */
/* Updated: 2022/12/07 14:15:24 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
void ft_p(unsigned int *tab_src, unsigned int *tab_dst)
{
unsigned int i;
i = ft_tablen(tab_dst) + 1;
while (i > 0)
{
tab_dst[i] = tab_dst[i - 1];
i--;
}
tab_dst[0] = tab_src[0];
i = 0;
while (tab_src[i] != STOP_VALUE)
{
tab_src[i] = tab_src[i + 1];
i++;
}
}
void ft_pb(unsigned int *tab_a, unsigned int *tab_b)
{
ft_p(tab_a, tab_b);
ft_putstr("pb\n");
}
void ft_pa(unsigned int *tab_a, unsigned int *tab_b)
{
ft_p(tab_b, tab_a);
ft_putstr("pa\n");
}