Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. int ShowTree(TREE *root, int N)
  2. {
  3.     size_t level = 0, res = 0;
  4.     q = NULL;
  5.     TREE *t;
  6.     TREE *z;
  7.     t = NULL;
  8.     Put(root);
  9.     Put(t);
  10.     while (!Empty(q))
  11.     {
  12.         t = Get();
  13.         if (t == NULL)
  14.         {
  15.             level++;
  16.             Put(NULL);
  17.             if (level == N)
  18.             break;
  19.         }
  20.         else
  21.         {
  22.             if (t->left != NULL)
  23.                 Put(t->left);
  24.             if (t->right != NULL)
  25.                 Put(t->right);
  26.             printf("%d ", t->inf);
  27.         }
  28.     }
  29.     while (!Empty(q))
  30.     {
  31.         z = Get();
  32.         res = res + 1;
  33.     }
  34.     return res;
  35.     puts("");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement