From 89c4b4ee4455ec3b4d8c70b14f08c684f2677c4a Mon Sep 17 00:00:00 2001 From: Xamora Date: Thu, 1 Dec 2022 15:52:29 +0100 Subject: [PATCH] J'avance --- push_swap.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/push_swap.c b/push_swap.c index 5d575c0..1bf7741 100644 --- a/push_swap.c +++ b/push_swap.c @@ -15,7 +15,7 @@ #include -void get_index(int **tab) +void get_index(int **tab,int len) { int i; int y; @@ -27,10 +27,10 @@ void get_index(int **tab) min = *tab[0]; old_min = *tab[0]; new_index = 0; - while (*tab[++i] != NULL) + while (++i < len) { y = -1; - while (*tab[++y] != NULL) + while (++y < len) { if (*tab[y] < min && *tab[y] <= old_min) { @@ -40,18 +40,15 @@ void get_index(int **tab) old_min = min; } } - for (i = 0 ; tab[i] != NULL ; i++) + for (i = 0 ; i < len ; i++) { - printf("%d", tab[i]); + printf("%d", *tab[i]); } } -void push_swap(int *tab, int argc) +void push_swap(int *tab, int len) { - int *index; - - index = malloc(sizeof(int) * (argc + 1)); - get_index(&tab); + get_index(&tab, len); } int main(int argc, char *argv[]) @@ -59,11 +56,10 @@ int main(int argc, char *argv[]) int *tab; int i; int y; - int test; - tab = malloc(sizeof(int) * (argc + 1)); i = 0; y = 0; + tab = malloc(sizeof(int) * (argc + 1)); if (argc > 1) { while (++i < argc) @@ -76,8 +72,7 @@ int main(int argc, char *argv[]) return (1); } } - tab[y] = NULL; - get_index(&tab); + get_index(&tab, y); //push_swap(tab, argc); }