1
0

test.h 707 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // Created by 李洋 on 2023/10/18.
  3. //
  4. #ifndef LEECODE_C_TEST_H_P
  5. #define LEECODE_C_TEST_H_P
  6. #include <queue>
  7. #include <iostream>
  8. using namespace std;
  9. void testPQ() {
  10. priority_queue<int, deque<int>, less<>> maxHeap;
  11. maxHeap.push(1);
  12. maxHeap.push(10);
  13. maxHeap.push(3);
  14. maxHeap.push(3);
  15. maxHeap.push(3);
  16. cout << maxHeap.top() << endl;
  17. maxHeap.pop();
  18. maxHeap.push(4);
  19. cout << maxHeap.top() << endl;
  20. maxHeap.pop();
  21. maxHeap.push(2);
  22. cout << maxHeap.top() << endl;
  23. priority_queue<int, vector<int>, greater<>> minHeap;
  24. minHeap.push(20);
  25. minHeap.push(10);
  26. minHeap.push(30);
  27. cout << minHeap.top() << endl;
  28. }
  29. #endif //LEECODE_C_TEST_H_P
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。