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;
|
t_list *sort;
|
||||||
int *i;
|
int *i;
|
||||||
int j;
|
int j;
|
||||||
int *x;
|
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
i = (int *)ft_calloc(3, sizeof(int));
|
|
||||||
sort = NULL;
|
sort = NULL;
|
||||||
while(a)
|
while(a)
|
||||||
{
|
{
|
||||||
if(sort){x = sort->content; ft_printf("[%i / ", x[0]);}
|
i = (int *)ft_calloc(3, sizeof(int));
|
||||||
|
|
||||||
i[0] = a->n;
|
i[0] = a->n;
|
||||||
i[1] = j;
|
i[1] = j;
|
||||||
i[2] = 0;
|
i[2] = 0;
|
||||||
|
|
||||||
if(sort){x = sort->content; ft_printf("%i] ", x[0]);}
|
|
||||||
|
|
||||||
ft_lstadd_back(&sort, ft_lstnew(i));
|
ft_lstadd_back(&sort, ft_lstnew(i));
|
||||||
|
|
||||||
x = sort->content; ft_printf("[%i]\n", x[0]);
|
|
||||||
|
|
||||||
a = a->next;
|
a = a->next;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -36,17 +27,7 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *solution)
|
|||||||
(void)b;
|
(void)b;
|
||||||
(void)a;
|
(void)a;
|
||||||
(void)solution;
|
(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);
|
sa(a, &solution);
|
||||||
pb(b, a, &solution);
|
pb(b, 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);
|
sa(a, &solution);
|
||||||
rra(a, &solution);
|
rra(a, &solution);
|
||||||
rrb(b, &solution);
|
rrb(b, &solution);
|
||||||
|
/*
|
||||||
rrr(a, b, &solution);
|
rrr(a, b, &solution);
|
||||||
ra(a, &solution);
|
ra(a, &solution);
|
||||||
rb(b, &solution);
|
rb(b, &solution);
|
||||||
|
|||||||
13
srcs/print.c
13
srcs/print.c
@@ -17,18 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
void fill_solution(t_list *solution, char *sp)
|
void fill_solution(t_list *solution, char *sp)
|
||||||
{
|
{
|
||||||
t_stack **tmp1;
|
|
||||||
t_stack **tmp2;
|
|
||||||
t_stack *a;
|
t_stack *a;
|
||||||
t_stack *b;
|
t_stack *b;
|
||||||
char *stack;
|
char *stack;
|
||||||
|
|
||||||
tmp1 = solution->content;
|
a = *(t_stack **)(solution->content);
|
||||||
tmp2 = solution->next->content;
|
b = *(t_stack **)(solution->next->content);
|
||||||
a = *tmp1;
|
stack = ft_strjoinfree(ft_strdup(sp), ft_strdup("!a:"));
|
||||||
b = *tmp2;
|
|
||||||
stack = ft_strdup(sp);
|
|
||||||
stack = ft_strjoinfree(stack, ft_strdup("!a:"));
|
|
||||||
while(a != NULL)
|
while(a != NULL)
|
||||||
{
|
{
|
||||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||||
@@ -36,7 +31,7 @@ void fill_solution(t_list *solution, char *sp)
|
|||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
stack = ft_strjoinfree(stack, ft_strdup("!b:"));
|
stack = ft_strjoinfree(stack, ft_strdup("!b:"));
|
||||||
while(b)
|
while(b != NULL)
|
||||||
{
|
{
|
||||||
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
stack = ft_strjoinfree(stack, ft_strdup(" "));
|
||||||
stack = ft_strjoinfree(stack, ft_itoa(b->n));
|
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);
|
solution = ft_lstnew(&a);
|
||||||
ft_lstadd_back(&solution, ft_lstnew(&b));
|
ft_lstadd_back(&solution, ft_lstnew(&b));
|
||||||
if (flag)
|
if (flag)
|
||||||
fill_solution(solution, ft_strdup("start"));
|
fill_solution(solution, "start");
|
||||||
hugo_sort(&a, &b, solution);
|
hugo_sort(&a, &b, solution);
|
||||||
//bubble_sort(&a, &b, solution);
|
//bubble_sort(&a, &b, solution);
|
||||||
return (solution);
|
return (solution);
|
||||||
|
|||||||
Reference in New Issue
Block a user