提交 a56ce2a9 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 f5455294
......@@ -5,14 +5,14 @@ int main(int argc, char* argv[])
int i;
//
// 初始化数组
// Initializing array
//
int WeightArray[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41};
int Count = sizeof(WeightArray) / sizeof(WeightArray[0]);
int HuffmanLength = 2 * Count - 1;
//
// 初始化赫夫曼树
// Initialize the Huffman tree
//
PHtTree pTree = (PHtTree)malloc(sizeof(HtTree));
pTree->HtArray = (HtNode*)malloc(sizeof(HtNode) * HuffmanLength);
......@@ -26,14 +26,14 @@ int main(int argc, char* argv[])
}
//
// 构造赫夫曼树
// Construction of Huffman tree
//
pTree = HuffmanTree(pTree, Count);
OutputResult(pTree, HuffmanLength);
//
// 销毁赫夫曼树
// Destruction tree hoffman
//
free(pTree->HtArray);
free(pTree);
......@@ -43,20 +43,20 @@ int main(int argc, char* argv[])
/*
function:
用给定的一组权值构造赫夫曼树.
Hoffman tree is constructed using a given set of weights.
parameter:
pTree -- 赫夫曼树结构体指针
Count -- 数组元素个数
pTree -- Hoffman tree structure pointer
Count -- The count of array elements
returned value:
返回赫夫曼树结构体指针.
Returns the pointer to the Huffman tree structure.
*/
PHtTree HuffmanTree(PHtTree pTree, int Count)
{
int i, j; // Cursor, which is mainly used to find the index of the smallest node and the second smallest node
int Index1, Index2; // 存放最小和次小节点下标
int Number1, Number2; // 存放最小和次小节点权值
int Index1, Index2; // Holds the subscript of the smallest and subsmallest nodes
int Number1, Number2; // Store minimum and sub - small node weights
//
// TODO: Add the code here
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论