Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lab027
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
DS Lab Group
实验项目模板
Lab027
提交
4879c609
提交
4879c609
8月 14, 2019
创建
作者:
宋海霞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
61532378
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
18 行增加
和
24 行删除
+18
-24
QuickSort.h
QuickSort.h
+0
-5
Stack.c
Stack.c
+8
-4
Stack.h
Stack.h
+3
-12
main.c
main.c
+7
-3
没有找到文件。
QuickSort.h
浏览文件 @
4879c609
#ifndef QUICKSORT_H_
#define QUICKSORT_H_
//
// Include the C standard library header file here
//
#include <stdio.h>
//
// Other header files are included here
//
#include "Stack.h"
//
// Define the data structure here
//
//
// Declare the function here
//
void
QuickSort
(
int
*
list
,
int
left
,
int
right
);
//
...
...
Stack.c
浏览文件 @
4879c609
...
...
@@ -30,8 +30,10 @@ int Push(Stack* pS, int Elem)
//
// Stack full, push failed.
//
if
(
MAX_STACK_LENGTH
-
1
<
pS
->
top
)
return
;
if
(
MAX_STACK_LENGTH
-
1
<
pS
->
top
)
{
return
;
}
pS
->
top
++
;
pS
->
buffer
[
pS
->
top
]
=
Elem
;
// Insert the element at the top of the stack
...
...
@@ -56,8 +58,10 @@ int Pop(Stack* pS)
//
// The stack is empty and the pop fails
//
if
(
StackEmpty
(
pS
))
return
;
if
(
StackEmpty
(
pS
))
{
return
;
}
Elem
=
pS
->
buffer
[
pS
->
top
];
pS
->
top
--
;
...
...
Stack.h
浏览文件 @
4879c609
#ifndef STACK_H_
#define STACK_H_
//
// Include the C standard library header file here
//
//
// Other header files are included here
//
//
// Define the data structure here
//
...
...
@@ -22,12 +17,12 @@
// Stack
typedef
struct
Stack
{
typedef
struct
Stack
{
int
buffer
[
MAX_STACK_LENGTH
];
// Stack buffer
int
top
;
// Indicates the position at the top of the stack, not the number of elements in the stack
int
top
;
// Indicates the position at the top of the stack, not the number of elements in the stack
}
Stack
;
//
// Declare the function here
//
...
...
@@ -37,12 +32,8 @@ int Push(Stack* pS, int Elem);
int
Pop
(
Stack
*
pS
);
int
StackEmpty
(
Stack
*
pS
);
//
// Declare global variables here
//
#endif
/* STACK_H_ */
main.c
浏览文件 @
4879c609
...
...
@@ -25,8 +25,10 @@ int main(int argc, char* argv[])
//
// Output the sorted result
//
for
(
i
=
0
;
i
<
length
;
i
++
)
for
(
i
=
0
;
i
<
length
;
i
++
)
{
printf
(
"%d "
,
list
[
i
]);
}
return
0
;
}
...
...
@@ -42,8 +44,10 @@ parameter:
*/
void
QuickSort
(
int
*
list
,
int
left
,
int
right
)
{
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
temp
;
// Temporary variables used to store partition elements
// 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
;
//
// TODO: Add the code here
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论