Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- struct Broj
- {
- int unos;
- struct Broj *next;
- };
- int UmetniIza(struct Broj *head, struct Broj *pocetak);
- int main()
- {
- struct Broj head;
- struct Broj pocetak;
- head.next = NULL;
- UmetniIza(&head, &pocetak);
- UmetniIza(&head, &pocetak);
- UmetniIza(&head, &pocetak);
- return 0;
- }
- int UmetniIza(struct Broj *head, struct Broj *pocetak)
- {
- struct Broj *q = (struct Broj*)malloc(sizeof(struct Broj));
- static int brojac = 0;
- pocetak = head;
- printf("Upisi broj\n");
- scanf("%d", &q->unos);
- if (head->next == NULL)
- {
- q->next = q;
- head->next = q;
- brojac += 1;
- }
- else
- {
- for (int i = 0; i < brojac; i++)
- {
- head = head->next;
- }
- head->next = q;
- q->next = pocetak->next;
- brojac += 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement