Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct cvor
- {
- int val;
- struct cvor *l, *r;
- }BCVOR;
- void umetni (BCVOR **root, BCVOR *x)
- {
- if (*root==NULL)
- {
- *root=x;
- x->l=NULL;
- x->r=NULL;
- }
- else if (x->val < (*root)->val) umetni(&(*root)->l, x);
- else umetni(&(*root)->r, x);
- }
- int main()
- {
- BCVOR *root=(BCVOR *)malloc(sizeof (BCVOR));
- root=NULL;
- int x;
- while (scanf ("%d", &x))
- {
- BCVOR *novi=(BCVOR *)malloc(sizeof (BCVOR));
- novi->val=x;
- umetni (&root, novi);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement