changment dans basic.c et dans double.c
Tests TP prog-104-p-02-2030 / test (push) Failing after 8s

This commit is contained in:
2026-04-03 16:54:34 +02:00
parent 72a13f7a19
commit 40d224a8f8
2 changed files with 12 additions and 3 deletions
@@ -53,9 +53,12 @@ int list_insert(struct list **l, size_t index, int e){
if(index == 0){ if(index == 0){
*l = list_append(*l, e);
/*
new_node->data = e; new_node->data = e;
new_node->next = *l; new_node->next = *l;
*l = new_node; *l = new_node;
*/
return 0; return 0;
} }
@@ -20,13 +20,19 @@ struct dlist *dlist_append(struct dlist *l, int e)
int dlist_insert(struct dlist **l, size_t index, int e) int dlist_insert(struct dlist **l, size_t index, int e)
{ {
struct dlist *tmp = *l; if(!l) return 1;
struct dlist *new_node = malloc(sizeof(struct dlist));
if(!new_node) return 1;
//struct dlist *tmp = *l;
if(index == 0){ if(index == 0){
dlist_append(*l, e); dlist_append(*l, e);
return 0; return 0;
} }
struct dlist *tmp = *l;
size_t ind = 0; size_t ind = 0;
while(tmp != NULL && ind < index - 1){ while(tmp != NULL && ind < index - 1){
@@ -36,8 +42,8 @@ int dlist_insert(struct dlist **l, size_t index, int e)
if(!tmp) return 1; if(!tmp) return 1;
struct dlist *new_node = malloc(sizeof(struct dlist)); //struct dlist *new_node = malloc(sizeof(struct dlist));
if(!new_node) return 1; //if(!new_node) return 1;
new_node->data = e; new_node->data = e;
new_node->next = tmp; new_node->next = tmp;