minheap.cpp
来自「一本全面剖析C++数据结构算法的书籍」· C++ 代码 · 共 29 行
CPP
29 行
// test min heap class#include <iostream.h>#include "minheap.h"void main(void){ MinHeap<int> H(4); int x; H.Insert(10).Insert(20).Insert(5); cout << "Elements in array order" << endl; H.Output(); try {H.Insert(15); cout << "Insert of 15 succeeded" << endl; H.Insert(30); cout << "Insert of 30 succeeded" << endl;} catch (NoMem) {cout << "An insert has failed" << endl;} cout << "Elements in array order" << endl; H.Output(); cout << "The min element is " << H.Min() << endl; H.DeleteMin(x); cout << "Deleted min element " << x << endl; H.DeleteMin(x); cout << "Deleted min element " << x << endl; cout << "Elements in array order" << endl; H.Output();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?