摘要: // Binary Heap #include #include #include #include #include #include #include using namespace std; template class MaxHeap { private : Item * data; int count; int capacity; void ... 阅读全文
posted @ 2019-03-25 20:32 青衫客36 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; template class BST { public : BST() { root = NULL; count = 0; } ~BST() { // TODO : ~BST() destroy(root... 阅读全文
posted @ 2019-03-25 19:20 青衫客36 阅读(108) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; // 非递归 template int binarySearch(T arr[], int n, T target) { int l = 0, r = n - 1; while(l int _binarySearch2(T arr[], int l, int r, T target) { if(l >... 阅读全文
posted @ 2019-03-25 16:16 青衫客36 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目描述 小明看到一本书上写着:任何数字的立方都可以表示为连续奇数的和。 比如: 2^3 = 8 = 3 + 5 3^3 = 27 = 7 + 9 + 11 虽然他没有想出怎么证明,但他想通过计算机进行验证。 所以聪明的你快来帮小明证明吧,你的工作就是要找出任何数字的立方的连续奇数之和的表示,如上式 阅读全文
posted @ 2019-03-25 13:09 青衫客36 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 题目描述 在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。 如2 4 3 1中,2 1,4 3,4 1,3 1是逆序,逆序数是4。给出一个整数序列,求该序列的逆序数。 输入 第1行:N,N为序列的长度(n 阅读全文
posted @ 2019-03-25 13:07 青衫客36 阅读(168) 评论(0) 推荐(0) 编辑