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

modify

上级 81c6fd0f
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
/* /*
功能: function:
初始化栈。 Initialize the stack.
参数: parameter:
pS -- 栈的指针 pS -- The stack pointer
*/ */
void InitStack(Stack* pS) void InitStack(Stack* pS)
{ {
...@@ -14,47 +14,47 @@ void InitStack(Stack* pS) ...@@ -14,47 +14,47 @@ void InitStack(Stack* pS)
} }
/* /*
功能: function:
将元素入栈。 Push elements on the stack.
参数: parameter:
pS -- 栈的指针 pS -- The stack pointer
Elem -- 入栈的元素 Elem -- Pushed elements
返回值: returned value:
如果插入成功返回入栈元素的值。 Returns the value of the pushed element if the insert succeeds.
如果插入失败返回 -1。 Returns -1 if insert fails.
*/ */
int Push(Stack* pS, int Elem) int Push(Stack* pS, int Elem)
{ {
// //
// 栈满,入栈失败。 // Stack full, push failed.
// //
if(MAX_STACK_LENGTH-1 < pS->top) if(MAX_STACK_LENGTH-1 < pS->top)
return ; return ;
pS->top++; pS->top++;
pS->buffer[pS->top] = Elem; // 将元素插入栈顶 pS->buffer[pS->top] = Elem; // Insert the element at the top of the stack
return Elem; return Elem;
} }
/* /*
功能: function:
将栈顶元素出栈 Pop the top element of the stack
参数: parameter:
pS -- 栈的指针 pS -- The stack pointer
返回值: returned value:
如果出栈成功返回出栈元素的值。 If the pop succeeds, the value of the pop element is returned.
如果出栈失败返回 -1。 Returns -1 if pop fails.
*/ */
int Pop(Stack* pS) int Pop(Stack* pS)
{ {
int Elem; int Elem;
// //
// 栈为空,出栈失败 // The stack is empty and the pop fails
// //
if(StackEmpty(pS)) if(StackEmpty(pS))
return ; return ;
...@@ -66,15 +66,15 @@ int Pop(Stack* pS) ...@@ -66,15 +66,15 @@ int Pop(Stack* pS)
} }
/* /*
功能: function:
判断栈是否为空。 Determines whether the stack is empty.
参数: parameter:
pQ -- 栈的指针 pQ -- The stack pointer
返回值: returned value:
如果栈空返回 1(真) Returns 1 if stack is empty.
如果栈非空返回 0(假) Returns 0 if the stack is not empty.
*/ */
int StackEmpty(Stack* pS) int StackEmpty(Stack* pS)
{ {
......
#include "QuickSort.h" #include "QuickSort.h"
Stack stack; // 栈用于储存分治范围 Stack stack; // 栈.用于储存分治范围
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
...@@ -13,7 +13,7 @@ int main(int argc, char* argv[]) ...@@ -13,7 +13,7 @@ int main(int argc, char* argv[])
int length = sizeof(list) / sizeof(list[0]); int length = sizeof(list) / sizeof(list[0]);
// //
// 初始化栈 // Initialize the stack
// //
InitStack(&stack); InitStack(&stack);
...@@ -32,10 +32,10 @@ int main(int argc, char* argv[]) ...@@ -32,10 +32,10 @@ int main(int argc, char* argv[])
} }
/* /*
功能: function:
快速排序。按关键字递增排序。 快速排序.按关键字递增排序.
参数: parameter:
list -- 数组指针 list -- 数组指针
left -- 分治范围(左边界) left -- 分治范围(左边界)
right -- 分治范围(右边界) right -- 分治范围(右边界)
...@@ -43,10 +43,10 @@ int main(int argc, char* argv[]) ...@@ -43,10 +43,10 @@ int main(int argc, char* argv[])
void QuickSort(int* list, int left, int right) void QuickSort(int* list, int left, int right)
{ {
int temp; // 用于储存分区元素的临时变量 int temp; // 用于储存分区元素的临时变量
int i, j; // i, j 分治区域两端的游标用来调整分区范围内的数据 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
// //
// TODO: 在此添加代码 // TODO: Add the code here
// //
return; return;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论