📄 heap.cpp
字号:
// Heap.cpp: implementation of the Heap class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HeapSort.h"
#include "Heap.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Heap::Heap()
{
n = N - 1;
Heapnode[1].style = false;
Heapnode[2].style = false;
Heapnode[3].style = false;
Heapnode[4].style = false;
Heapnode[5].style = false;
Heapnode[6].style = false;
Heapnode[7].style = false;
Heapnode[8].style = false;
Heapnode[9].style = false;
Heapnode[10].style = false;
Heapnode[11].style = false;
Heapnode[12].style = false;
Heapnode[13].style = false;
Heapnode[14].style = false;
Heapnode[15].style = false;
Heapnode[16].style = false;
Heapnode[1].key = "91";
Heapnode[2].key = "67";
Heapnode[3].key = "35";
Heapnode[4].key = "62";
Heapnode[5].key = "29";
Heapnode[6].key = "72";
Heapnode[7].key = "46";
Heapnode[8].key = "31";
Heapnode[9].key = "47";
Heapnode[10].key = "25";
Heapnode[11].key = "83";
Heapnode[12].key = "79";
Heapnode[13].key = "13";
Heapnode[14].key = "80";
Heapnode[15].key = "19";
Heapnode[16].key = "74";
}
Heap::~Heap()
{
}
void Heap::reset(CRect r)
{
n = N - 1;
Heapnode[1].style = false;
Heapnode[2].style = false;
Heapnode[3].style = false;
Heapnode[4].style = false;
Heapnode[5].style = false;
Heapnode[6].style = false;
Heapnode[7].style = false;
Heapnode[8].style = false;
Heapnode[9].style = false;
Heapnode[10].style = false;
Heapnode[11].style = false;
Heapnode[12].style = false;
Heapnode[13].style = false;
Heapnode[14].style = false;
Heapnode[15].style = false;
Heapnode[16].style = false;
Heapnode[1].key = "91";
Heapnode[2].key = "67";
Heapnode[3].key = "35";
Heapnode[4].key = "62";
Heapnode[5].key = "29";
Heapnode[6].key = "72";
Heapnode[7].key = "46";
Heapnode[8].key = "31";
Heapnode[9].key = "47";
Heapnode[10].key = "25";
Heapnode[11].key = "83";
Heapnode[12].key = "79";
Heapnode[13].key = "13";
Heapnode[14].key = "80";
Heapnode[15].key = "19";
Heapnode[16].key = "74";
Heapnode[1].Locate = CPoint( r.right/2,5*r.bottom/30);
Heapnode[2].Locate = CPoint( r.right/4,11*r.bottom/30);
Heapnode[3].Locate = CPoint( 3*r.right/4,11*r.bottom/30);
Heapnode[4].Locate = CPoint( r.right/8,17*r.bottom/30);
Heapnode[5].Locate = CPoint( 3*r.right/8,17*r.bottom/30);
Heapnode[6].Locate = CPoint( 5*r.right/8,17*r.bottom/30);
Heapnode[7].Locate = CPoint( 7*r.right/8,17*r.bottom/30);
Heapnode[8].Locate = CPoint( r.right/16,21*r.bottom/30);
Heapnode[9].Locate = CPoint( 3*r.right/16,21*r.bottom/30);
Heapnode[10].Locate = CPoint( 5*r.right/16,21*r.bottom/30);
Heapnode[11].Locate = CPoint( 7*r.right/16,21*r.bottom/30);
Heapnode[12].Locate = CPoint( 9*r.right/16,21*r.bottom/30);
Heapnode[13].Locate = CPoint(11*r.right/16,21*r.bottom/30);
Heapnode[14].Locate = CPoint(13*r.right/16,21*r.bottom/30);
Heapnode[15].Locate = CPoint(15*r.right/16,21*r.bottom/30);
Heapnode[16].Locate = CPoint( r.right/32,27*r.bottom/30);
Heapnode[1].Parent = CPoint(-10,-10);
Heapnode[2].Parent = Heapnode[2/2].Locate;
Heapnode[3].Parent = Heapnode[3/2].Locate;
Heapnode[4].Parent = Heapnode[4/2].Locate;
Heapnode[5].Parent = Heapnode[5/2].Locate;
Heapnode[6].Parent = Heapnode[6/2].Locate;
Heapnode[7].Parent = Heapnode[7/2].Locate;
Heapnode[8].Parent = Heapnode[8/2].Locate;
Heapnode[9].Parent = Heapnode[9/2].Locate;
Heapnode[10].Parent = Heapnode[10/2].Locate;
Heapnode[11].Parent = Heapnode[11/2].Locate;
Heapnode[12].Parent = Heapnode[12/2].Locate;
Heapnode[13].Parent = Heapnode[13/2].Locate;
Heapnode[14].Parent = Heapnode[14/2].Locate;
Heapnode[15].Parent = Heapnode[15/2].Locate;
Heapnode[16].Parent = Heapnode[16/2].Locate;
}
void Heap::SetNode(CRect r)
{
Heapnode[1].Locate = CPoint( r.right/2,5*r.bottom/30);
Heapnode[2].Locate = CPoint( r.right/4,11*r.bottom/30);
Heapnode[3].Locate = CPoint( 3*r.right/4,11*r.bottom/30);
Heapnode[4].Locate = CPoint( r.right/8,17*r.bottom/30);
Heapnode[5].Locate = CPoint( 3*r.right/8,17*r.bottom/30);
Heapnode[6].Locate = CPoint( 5*r.right/8,17*r.bottom/30);
Heapnode[7].Locate = CPoint( 7*r.right/8,17*r.bottom/30);
Heapnode[8].Locate = CPoint( r.right/16,21*r.bottom/30);
Heapnode[9].Locate = CPoint( 3*r.right/16,21*r.bottom/30);
Heapnode[10].Locate = CPoint( 5*r.right/16,21*r.bottom/30);
Heapnode[11].Locate = CPoint( 7*r.right/16,21*r.bottom/30);
Heapnode[12].Locate = CPoint( 9*r.right/16,21*r.bottom/30);
Heapnode[13].Locate = CPoint(11*r.right/16,21*r.bottom/30);
Heapnode[14].Locate = CPoint(13*r.right/16,21*r.bottom/30);
Heapnode[15].Locate = CPoint(15*r.right/16,21*r.bottom/30);
Heapnode[16].Locate = CPoint( r.right/32,27*r.bottom/30);
Heapnode[1].Parent = CPoint(-10,-10);
Heapnode[2].Parent = Heapnode[2/2].Locate;
Heapnode[3].Parent = Heapnode[3/2].Locate;
Heapnode[4].Parent = Heapnode[4/2].Locate;
Heapnode[5].Parent = Heapnode[5/2].Locate;
Heapnode[6].Parent = Heapnode[6/2].Locate;
Heapnode[7].Parent = Heapnode[7/2].Locate;
Heapnode[8].Parent = Heapnode[8/2].Locate;
Heapnode[9].Parent = Heapnode[9/2].Locate;
Heapnode[10].Parent = Heapnode[10/2].Locate;
Heapnode[11].Parent = Heapnode[11/2].Locate;
Heapnode[12].Parent = Heapnode[12/2].Locate;
Heapnode[13].Parent = Heapnode[13/2].Locate;
Heapnode[14].Parent = Heapnode[14/2].Locate;
Heapnode[15].Parent = Heapnode[15/2].Locate;
Heapnode[16].Parent = Heapnode[16/2].Locate;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -