2019.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <vector>
  2. using namespace std;
  3. void odd_even(vector<int> &array)
  4. {
  5. int left = 0;
  6. int right = array.size() - 1;
  7. while (left < right)
  8. {
  9. while (left < right && array[right] % 2 == 0)
  10. {
  11. right--;
  12. }
  13. while (left < right && array[left] % 2 == 1)
  14. {
  15. left++;
  16. }
  17. swap(array[left], array[right]);
  18. }
  19. }
  20. #include "../structs/Tree.h"
  21. void insertSearchTree(TreeNode *root, int value)
  22. {
  23. TreeNode *dist = new TreeNode();
  24. dist->val = value;
  25. if (!root)
  26. {
  27. root = dist;
  28. }
  29. TreeNode *temp = root;
  30. while (temp)
  31. {
  32. if (temp->val > value)
  33. {
  34. if (temp->left)
  35. {
  36. temp = temp->left;
  37. continue;
  38. }
  39. temp->left = dist;
  40. break;
  41. }
  42. if (temp->val < value)
  43. {
  44. if (temp->right)
  45. {
  46. temp = temp->right;
  47. continue;
  48. }
  49. temp->left = dist;
  50. break;
  51. }
  52. if (temp->val == value)
  53. {
  54. break;
  55. }
  56. }
  57. }
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。