Skip to content

Commit

Permalink
adding rules to sort 3nbrs
Browse files Browse the repository at this point in the history
  • Loading branch information
biralavor committed Jun 6, 2024
1 parent 00aa7f2 commit a7be7cb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions program_to_test/src/ft_sort_until3.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/04 12:19:14 by umeneses #+# #+# */
/* Updated: 2024/06/05 15:55:12 by umeneses ### ########.fr */
/* Updated: 2024/06/06 17:28:46 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,8 +45,16 @@ t_stack *ft_sort_3_nbrs(t_stack **list)
if (((*list)->next->nbr < (*list)->nbr)
&& ((*list)->next->nbr < ft_lst_goto_end(*list)->nbr))
ft_do_rotate_a(list);
else
if (((*list)->nbr < ft_lst_goto_end(*list)->nbr)
&& ((*list)->nbr < ft_lst_goto_before_end(*list)->nbr))
{
ft_do_swap_a(list);
ft_do_rotate_a(list);
}
if ((ft_lst_goto_head(*list)->nbr > ft_lst_goto_head(*list)->next->nbr)
&& (ft_lst_goto_head(*list)->nbr > ft_lst_goto_end(*list)->nbr))
ft_do_swap_a(list);
ft_lst_printf_int_content("after sort 3nbrs:", *list);
}
return (*list);
}

0 comments on commit a7be7cb

Please sign in to comment.