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

modify

上级 50f00286
#include "QuickSort.h" #include "QuickSort.h"
Stack stack; // 栈.用于储存分治范围 Stack stack; // Stack.For storage divide and conquer range
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int i; int i;
// //
// 初始化数组 // Initializing array
// //
int list[] = {49, 38, 65, 97, 76}; int list[] = {49, 38, 65, 97, 76};
int length = sizeof(list) / sizeof(list[0]); int length = sizeof(list) / sizeof(list[0]);
...@@ -18,12 +18,12 @@ int main(int argc, char* argv[]) ...@@ -18,12 +18,12 @@ int main(int argc, char* argv[])
InitStack(&stack); InitStack(&stack);
// //
// 快速排序 // Quick sort
// //
QuickSort(list, 0, length-1); QuickSort(list, 0, length-1);
// //
// 输出排序后的结果 // Output the sorted result
// //
for(i=0; i<length; i++) for(i=0; i<length; i++)
printf("%d ", list[i]); printf("%d ", list[i]);
...@@ -33,16 +33,16 @@ int main(int argc, char* argv[]) ...@@ -33,16 +33,16 @@ int main(int argc, char* argv[])
/* /*
function: function:
快速排序.按关键字递增排序. Quick sort.Sort by keyword increments.
parameter: parameter:
list -- 数组指针 list -- Pointer to an array
left -- 分治范围(左边界) left -- Partition scope(The left border)
right -- 分治范围(右边界) right -- Partition scope(The right border)
*/ */
void QuickSort(int* list, int left, int right) void QuickSort(int* list, int left, int right)
{ {
int temp; // 用于储存分区元素的临时变量 int temp; // Temporary variables used to store partition elements
int i, j; // Cursors at both ends of the i, j divide and conquer region are used to adjust the data within the partition scope int i, j; // Cursors at both ends of the i, j divide and conquer region are used to adjust the data within the partition scope
// //
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论