-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7.3.13.c
45 lines (45 loc) · 1.1 KB
/
7.3.13.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
struct element
{
int i;
struct element *next;
};
void *dodaj(struct element *lista, int a)
{
struct element *wsk = malloc(sizeof(struct element));
wsk = lista;
while(wsk->next != NULL)
{
wsk = wsk->next;
}
wsk->next = malloc(sizeof(struct element));
wsk = wsk->next;
wsk->i = a;
wsk->next = NULL;
}
void wyswietlListeZGlowa(struct element *lista)
{
struct element *temp=lista->next;
while(temp!=NULL)
{
printf("%i\n", temp->i);
temp=temp->next;
}
printf("\n");
}
int main()
{
struct element *lista1 = malloc(sizeof(struct element));
lista1->next = malloc(sizeof(struct element));
lista1->next->i = 8;
lista1->next->next = malloc(sizeof(struct element));
lista1->next->next->i = 4;
lista1->next->next->next = malloc(sizeof(struct element));
lista1->next->next->next->i = 11;
lista1->next->next->next->next = NULL;
wyswietlListeZGlowa(lista1);
dodaj(lista1, 12);
wyswietlListeZGlowa(lista1);
return 0;
}