This commit is contained in:
Camille Chauvet 2022-12-09 19:17:57 +01:00
parent 55119130da
commit 224d9bb1a4
3 changed files with 18 additions and 43 deletions

View File

@ -6,12 +6,25 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 14:24:03 by cchauvet #+# #+# */
/* Updated: 2022/12/09 19:11:58 by cchauvet ### ########.fr */
/* Updated: 2022/12/09 19:14:50 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
static void ft_specific_bozo_sort(t_tab tab_a, t_tab tab_b)
{
if (tab_a[0] == tab_a[1] - 1)
ft_rra(tab_a);
if (tab_a[0] == tab_a[1] + 1 && tab_a[1] == tab_a[2] + 1)
{
ft_ra(tab_a);
ft_sa(tab_a);
}
if (tab_a[0] == tab_a[1] + 1)
ft_sa(tab_a);
}
void ft_bozo_sort(t_tab tab_a, t_tab tab_b)
{
if (ft_is_sorted(tab_a))
@ -22,15 +35,6 @@ void ft_bozo_sort(t_tab tab_a, t_tab tab_b)
ft_ra(tab_a);
ft_pb(tab_a, tab_b);
}
if (tab_a[0] == tab_a[1] - 1)
ft_rra(tab_a);
if (tab_a[0] == tab_a[1] + 1 && tab_a[1] == tab_a[2] + 1)
{
ft_ra(tab_a);
ft_sa(tab_a);
}
if (tab_a[0] == tab_a[1] + 1)
ft_sa(tab_a);
if (!ft_is_sorted(tab_a))
{
ft_pb(tab_a, tab_b);

2
ft_s.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 18:00:12 by cchauvet #+# #+# */
/* Updated: 2022/12/09 18:05:06 by cchauvet ### ########.fr */
/* Updated: 2022/12/09 19:15:57 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */

29
test.c
View File

@ -1,29 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/07 13:38:08 by cchauvet #+# #+# */
/* Updated: 2022/12/07 14:14:21 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int main()
{
unsigned int tab_a[10] = {0, 1, 2, 3, 4, STOP_VALUE};
unsigned int tab_b[10] = {5, STOP_VALUE};
int i;
printf("tab_a\n");
i = 0;
while (tab_a[i] != STOP_VALUE)
printf("%d\n", tab_a[i++]);
ft_pa(tab_a, tab_b);
i = 0;
while (tab_a[i] != STOP_VALUE)
printf("%d\n", tab_a[i++]);
}