#include <stdio.h>
#include <stdlib.h>
typedef struct element {
int dane;
struct element *next;
} ADRES;
void Dodaj(ADRES **head, int liczba)
{
int i=0;
ADRES *el_listy;
while(i<liczba)
{
el_listy = (ADRES*)malloc(sizeof(ADRES));
printf("Podaj %d liczbe: ", i+1);
scanf("%d", &el_listy->dane);
el_listy->next=NULL;
el_listy=el_listy->next;
i++;
}
}
void Pokaz_liste(ADRES *head)
{
if(head==NULL)
printf("Lista jest pusta!");
else
{
ADRES *el_listy=head;
while(el_listy->next!=NULL)
{
printf("%d", el_listy->dane);
el_listy=el_listy->next;
}
}
}
int main()
{
ADRES *head;
head =(ADRES*)malloc(sizeof(ADRES));
head=NULL;
int liczba;
printf("ILe chcesz dodac cyfr do listy?\n");
scanf("%d", &liczba);
if(liczba<0)
{
printf("Daj dodatnia\n");
}
Dodaj(&head, liczba);
Pokaz_liste(head);
return 0;
}