#include #include struct ll { int value; struct ll* next; }; struct ll* na_zaciatok(struct ll * first,int value) { struct ll* prvy = calloc(1,sizeof(struct ll)); prvy->value = value; prvy->next = first; return prvy; } struct ll* na_koniec(struct ll * first,int value) { struct ll* nova = calloc(1,sizeof(struct ll)); nova->value = value; if (first == NULL){ return nova; } struct ll* this = first; while(this->next != NULL){ this = this->next; } this->next = nova; return first; } void print_ll(struct ll* first){ struct ll* this = first; while(this != NULL){ printf("%d\n",this->value); this = this->next; } printf("------\n"); } void clear(struct ll* first){ struct ll* this = first; while(this != NULL){ struct ll* next = this->next; free(this); this = next; } } int main(){ struct ll* zoznam = NULL; na_koniec(zoznam,20); for (int i = 0; i < 10; i++){ zoznam = na_zaciatok(zoznam, i); print_ll(zoznam); } zoznam = na_koniec(zoznam,123); clear(zoznam); return 0; }