Untitled
nodo_t* no_duplicati(nodo_t* l) { if (l == NULL) { return NULL; } nodo_t* corrente = l; while (corrente != NULL && corrente->next != NULL) { nodo_t* prev = corrente; while (prev->next != NULL) { if (prev->next->num == corrente->num) { nodo_t* tmp = prev->next; prev->next = prev->next->next; free(tmp); } else { prev = prev->next; } } corrente = corrente->next; } return l; }
Leave a Comment