raccourcis de fillsolution
This commit is contained in:
BIN
builds/algo.o
BIN
builds/algo.o
Binary file not shown.
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
Binary file not shown.
22
srcs/algo.c
22
srcs/algo.c
@@ -6,25 +6,16 @@ t_list *dup_n_fill(t_stack *a)
|
||||
t_list *sort;
|
||||
int *i;
|
||||
int j;
|
||||
int *x;
|
||||
|
||||
j = 0;
|
||||
i = (int *)ft_calloc(3, sizeof(int));
|
||||
sort = NULL;
|
||||
while(a)
|
||||
{
|
||||
if(sort){x = sort->content; ft_printf("[%i / ", x[0]);}
|
||||
|
||||
i = (int *)ft_calloc(3, sizeof(int));
|
||||
i[0] = a->n;
|
||||
i[1] = j;
|
||||
i[2] = 0;
|
||||
|
||||
if(sort){x = sort->content; ft_printf("%i] ", x[0]);}
|
||||
|
||||
ft_lstadd_back(&sort, ft_lstnew(i));
|
||||
|
||||
x = sort->content; ft_printf("[%i]\n", x[0]);
|
||||
|
||||
a = a->next;
|
||||
j++;
|
||||
}
|
||||
@@ -36,17 +27,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
|
||||
(void)b;
|
||||
(void)a;
|
||||
(void)solution;
|
||||
t_list *sort;
|
||||
|
||||
sort = dup_n_fill(*a);
|
||||
int *i;
|
||||
while(sort)
|
||||
{
|
||||
i = sort->content;
|
||||
ft_printf("%i - %i - %i\n", i[0], i[1], i[2]);
|
||||
sort = sort->next;
|
||||
}
|
||||
/*
|
||||
sa(a, &solution);
|
||||
pb(b, a, &solution);
|
||||
pb(b, a, &solution);
|
||||
@@ -59,6 +40,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
|
||||
sa(a, &solution);
|
||||
rra(a, &solution);
|
||||
rrb(b, &solution);
|
||||
/*
|
||||
rrr(a, b, &solution);
|
||||
ra(a, &solution);
|
||||
rb(b, &solution);
|
||||
|
||||
13
srcs/print.c
13
srcs/print.c
@@ -17,18 +17,13 @@
|
||||
*/
|
||||
void fill_solution(t_list *solution, char *sp)
|
||||
{
|
||||
t_stack **tmp1;
|
||||
t_stack **tmp2;
|
||||
t_stack *a;
|
||||
t_stack *b;
|
||||
char *stack;
|
||||
|
||||
tmp1 = solution->content;
|
||||
tmp2 = solution->next->content;
|
||||
a = *tmp1;
|
||||
b = *tmp2;
|
||||
stack = ft_strdup(sp);
|
||||
stack = ft_strjoinfree(stack, ft_strdup("!a:"));
|
||||
a = *(t_stack **)(solution->content);
|
||||
b = *(t_stack **)(solution->next->content);
|
||||
stack = ft_strjoinfree(ft_strdup(sp), ft_strdup("!a:"));
|
||||
while(a != NULL)
|
||||
{
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||
@@ -36,7 +31,7 @@ void fill_solution(t_list *solution, char *sp)
|
||||
a = a->next;
|
||||
}
|
||||
stack = ft_strjoinfree(stack, ft_strdup("!b:"));
|
||||
while(b)
|
||||
while(b != NULL)
|
||||
{
|
||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||
stack = ft_strjoinfree(stack, ft_itoa(b->n));
|
||||
|
||||
@@ -53,7 +53,7 @@ t_list *launch_algo(t_stack *a, int flag)
|
||||
solution = ft_lstnew(&a);
|
||||
ft_lstadd_back(&solution, ft_lstnew(&b));
|
||||
if (flag)
|
||||
fill_solution(solution, ft_strdup("start"));
|
||||
fill_solution(solution, "start");
|
||||
hugo_sort(&a, &b, solution);
|
||||
//bubble_sort(&a, &b, solution);
|
||||
return (solution);
|
||||
|
||||
Reference in New Issue
Block a user