fichiers un peu mieux rangees
This commit is contained in:
65
srcs/minisort.c
Normal file
65
srcs/minisort.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "push_swap.h"
|
||||
|
||||
int find_biggest(t_stack *list, int size)
|
||||
{
|
||||
int biggest;
|
||||
int position;
|
||||
int i;
|
||||
|
||||
biggest = list->n;
|
||||
position = 1;
|
||||
i = 1;
|
||||
while (list && --size)
|
||||
{
|
||||
i++;
|
||||
list = list->next;
|
||||
if (biggest < list->n)
|
||||
{
|
||||
position = i;
|
||||
biggest = list->n;
|
||||
}
|
||||
}
|
||||
return (position);
|
||||
}
|
||||
|
||||
void push_biggest(t_stack **list, t_list *solution, int size, int big)
|
||||
{
|
||||
t_stack *head;
|
||||
int i;
|
||||
|
||||
head = *list;
|
||||
i = size;
|
||||
while (i--)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void minisort(t_stack **list, t_list *solution)
|
||||
{
|
||||
int list_size;
|
||||
int next_big;
|
||||
|
||||
list_size = sublist_size(*list);
|
||||
if(list_size == 1)
|
||||
return ;
|
||||
(*list)->limit = 0;
|
||||
next_big = find_biggest(*list, list_size);
|
||||
push_biggest(list, solution, list_size, next_big);
|
||||
(*list)->limit = 1;
|
||||
mark_step(solution, "minisort");
|
||||
}
|
||||
|
||||
/*
|
||||
t_stack *test;
|
||||
test = *list;
|
||||
int w;
|
||||
w = list_size;
|
||||
while (w--)
|
||||
{
|
||||
ft_printf("%i ", test->n);
|
||||
test = test->next;
|
||||
}
|
||||
ft_printf("%i\n", next_big);
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user