Ragazzi voi lo vedete? Io è piu di un ora che lo cerco uff![]()
codice:#include <stdio.h> #include <stdlib.h> typedef struct Elem { float value; struct Elem* next; } Elem, *NList; NList crea_lista(void); void stampa_lista(NList L); int main(void) { NList lista = crea_lista(); stampa_lista(lista); return 0; } NList crea_lista(void) { NList L; int ctrl; printf("1 - Inserire primo elemento\n0 - Laciare lista vuota\n? "); scanf("%d", &ctrl); if(ctrl == 0) { L = NULL; return L; } NList Lcpy = L; printf("Immettere float: "); scanf("%f", &L->value); printf("\n1 - Inserire altro elemento\n0 - Interrompere inserimento\n? "); scanf("%d", &ctrl); if(ctrl) { while(1) { Lcpy->next = malloc(sizeof(Elem)); Lcpy = Lcpy->next; printf("Immettere float: "); scanf("%f", &Lcpy->value); printf("\n1 - Inserire altro elemento\n0 - Interrompere inserimento\n? "); scanf("%d", &ctrl); if(!ctrl) break; } } Lcpy->next = NULL; return L; } void stampa_lista(NList L) { printf("Lista -> "); while(L != NULL) { printf("%.2f -> ", L->value); L = L->next; } printf("NULL\n"); }

