Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct _cvor *Position;
- void DodajUListu(Position head, int x);
- void IspisiListu(Position head);
- typedef struct _cvor
- {
- int el;
- Position next;
- }cvor;
- int main()
- {
- int broj = 5;
- int broj2 = 2;
- int broj3 = 4;
- Position head = NULL;
- head = (Position)malloc(sizeof(Position));
- head->next = head;
- DodajUListu(head,broj);
- DodajUListu(head, broj2);
- DodajUListu(head, broj3);
- IspisiListu(head);
- return 0;
- }
- void DodajUListu(Position head,int x)
- {
- Position g;
- Position temp;
- temp = head;
- g = (Position)malloc(sizeof(cvor));
- while (temp->next!=head)
- {
- temp = temp->next;
- }
- g->next = temp->next;
- temp->next = g;
- g->el = x;
- }
- void IspisiListu(Position head)
- {
- Position temp = head;
- while (head->next != temp)
- {
- head = head->next;
- printf("%d ", head->el);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement