Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public void Elements_on_Level(int x)
  2. {
  3. bool[] used = new bool[1000];
  4. Queue<Item> q = new Queue<Item>();
  5. q.Enqueue(root);
  6. used[root.info] = true;
  7.  
  8. while (q.Count != 0)
  9. {
  10.  
  11.  
  12. Item cur = q.Dequeue();
  13.  
  14. if (Find_on_Level(cur.info) == Find_on_Level(x))
  15. {
  16. Console.WriteLine("Точка: " + cur.ToString() + " находится на уровне + " + Find_on_Level(x).ToString());
  17. }
  18.  
  19. for (int i = 0; i < 2; i++)
  20. {
  21. if (i == 0)
  22. {
  23. q.Enqueue(cur.rSon);
  24. used[(cur.rSon).info] = true;
  25. }
  26. else if (i == 1)
  27. {
  28. q.Enqueue(cur.lSon);
  29. used[(cur.lSon).info] = true;
  30. }
  31. }
  32.  
  33.  
  34.  
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement