Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. if (str == "next")
  2. {
  3. bool f = 1, f2 = 1;
  4. int j = 1, suc = 0;
  5. while (j != 0)
  6. if (v[j].k > x)
  7. {
  8. f2 = 0;
  9. suc = j;
  10. j = v[j].l;
  11. }
  12. else if (v[j].r == 0 && f2)
  13. {
  14. f = 0;
  15. cout << "none\n";
  16. break;
  17. }
  18. else
  19. j = v[j].r;
  20. if (f)
  21. cout << v[suc].k <<"\n";
  22. }
  23.  
  24. if (str == "prev")
  25. {
  26. bool f = 1, f2 = 1;
  27. int j = 1, suc = 0;
  28. while (j != 0)
  29. if (v[j].k < x)
  30. {
  31. f2 = 0;
  32. suc = j;
  33. j = v[j].r;
  34. }
  35. else if (v[j].l == 0 && f2)
  36. {
  37. f = 0;
  38. cout << "none\n";
  39. break;
  40. }
  41. else
  42. j = v[j].l;
  43. if (f)
  44. cout << v[suc].k << "\n";
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement