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

modify

上级 58ce1188
...@@ -7,10 +7,10 @@ int main(int argc, char* argv[]) ...@@ -7,10 +7,10 @@ int main(int argc, char* argv[])
SortObject List; SortObject List;
// //
// 初始化线性表 // Initialize the linear table
// //
int InitList[] = { 26, 5, 77, 1, 61, 11, 59, 15, 48, 19 }; int InitList[] = { 26, 5, 77, 1, 61, 11, 59, 15, 48, 19 };
int n = sizeof(InitList) / sizeof(InitList[0]); // 计算线性表长度 int n = sizeof(InitList) / sizeof(InitList[0]); // Calculate the linear table length
List.Elements = (int*)malloc(sizeof(int) * n); List.Elements = (int*)malloc(sizeof(int) * n);
List.length = n; List.length = n;
for(i=0; i < List.length; i++) for(i=0; i < List.length; i++)
...@@ -32,45 +32,45 @@ int main(int argc, char* argv[]) ...@@ -32,45 +32,45 @@ int main(int argc, char* argv[])
} }
/* /*
功能: function:
由下向上把各层子树调整成为大根堆 由下向上把各层子树调整成为大根堆.
参数: parameter:
List -- 线性表指针 List -- Linear table pointer
size -- 线性表中用于构造大根堆的元素的个数 size -- The number of elements in the linear table used to construct the large root heap
i -- 指定开始构造大根堆的元素的起始位置。从 0 开始计数。 i -- 指定开始构造大根堆的元素的起始位置.从 0 开始计数.
返回值: returned value:
*/ */
void Sift(SortObject* List, int size, int i) void Sift(SortObject* List, int size, int i)
{ {
// //
// TODO: 在此添加代码 // TODO: Add the code here
// //
return; return;
} }
/* /*
功能: function:
堆排序 堆排序.
参数: parameter:
List -- 线性表指针 List -- Linear table pointer
返回值: returned value:
*/ */
void HeapSort(SortObject* List) void HeapSort(SortObject* List)
{ {
int i = 0; // 游标 int i = 0; // The cursor
int size = List->length; // 线性表中元素的个数 int size = List->length; // The number of elements in a linear table
int HeapSize = 0; // 线性表中用于构造大根堆的元素的个数 int HeapSize = 0; // The number of elements in the linear table used to construct the large root heap
// //
// TODO: 在此添加代码 // TODO: Add the code here
// //
return; return;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论