35 lines
1.2 KiB
C
35 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_s.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/11/08 20:12:44 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/11/17 01:06:50 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "pushswap.h"
|
||
|
|
||
|
void ft_s(int *tab)
|
||
|
{
|
||
|
int size;
|
||
|
|
||
|
size = ft_get_last_index(tab);
|
||
|
ft_swap(tab + size - 1, tab + size - 2);
|
||
|
}
|
||
|
|
||
|
void ft_ss(int *tab1, int *tab2)
|
||
|
{
|
||
|
int size1;
|
||
|
int size2;
|
||
|
|
||
|
size1 = ft_get_last_index(tab1);
|
||
|
size2 = ft_get_last_index(tab2);
|
||
|
if (size1 < 2 || size2 < 2)
|
||
|
return ;
|
||
|
ft_s(tab1);
|
||
|
ft_s(tab2);
|
||
|
}
|