Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lab016
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
DS Lab Group
实验项目模板
Lab016
提交
5e83cca8
提交
5e83cca8
5月 20, 2019
创建
作者:
宋海霞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify
上级
5528dd3f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
42 行增加
和
42 行删除
+42
-42
Queue.c
Queue.c
+28
-28
main.c
main.c
+14
-14
没有找到文件。
Queue.c
浏览文件 @
5e83cca8
...
...
@@ -2,11 +2,11 @@
/*
功能:
初始化队列。
function:
Initialization queue.
参数:
pQ --
队列指针
parameter:
pQ --
Pointer to a queue
*/
void
InitQueue
(
Queue
*
pQ
)
{
...
...
@@ -15,21 +15,21 @@ void InitQueue(Queue* pQ)
}
/*
功能:
将元素插入队尾。
function:
Insert the element at the end of the queue.
参数:
pQ --
队列指针
Elem --
入队的元素
parameter:
pQ --
Pointer to a queue
Elem --
Elements of enrolling
返回值:
如果插入成功返回入队元素的值。
如果插入失败返回 -1。
returned value:
Returns the value of the enqueued element if the insert is successful.
Returns -1 if insert fails.
*/
int
EnQueue
(
Queue
*
pQ
,
int
Elem
)
{
//
//
队列满,入队失败。
//
Queue full, fail to join.
//
if
(
MAX_QUEUE_LENGTH
==
pQ
->
length
)
return
-
1
;
...
...
@@ -42,22 +42,22 @@ int EnQueue(Queue* pQ, int Elem)
}
/*
功能:
将队首元素出队
function:
Remove the first element from the team
参数:
pQ --
队列指针
parameter:
pQ --
Pointer to a queue
返回值:
如果出队成功返回出队元素的值。
如果出队失败返回 -1。
returned value:
Returns the value of the queued element if queued successfully.
Returns -1 if dequeuing fails.
*/
int
DeQueue
(
Queue
*
pQ
)
{
int
Elem
;
//
//
队列空,出队失败
//
Queue empty, dequeue failed
//
if
(
QueueEmpty
(
pQ
))
return
-
1
;
...
...
@@ -70,15 +70,15 @@ int DeQueue(Queue* pQ)
}
/*
功能:
判断队列是否为空。
function:
Determines if the queue is empty.
参数:
pQ --
队列指针
parameter:
pQ --
Pointer to a queue
返回值:
如果队列空返回 1(真)
如果队列非空返回 0(假)
returned value:
Returns 1 if the queue is empty.
Returns 0 if the queue is non-empty.
*/
int
QueueEmpty
(
Queue
*
pQ
)
{
...
...
main.c
浏览文件 @
5e83cca8
#include "Graph.h"
int
visited
[
MAX_VERTEX_NUM
];
// 顶点访问标志数组
。0 表示未访问;大于 0 表示访问的先后次序。
int
visited
[
MAX_VERTEX_NUM
];
// 顶点访问标志数组
.0 表示未访问;大于 0 表示访问的先后次序.
Queue
queue
;
// 队列
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -52,35 +52,35 @@ int main(int argc, char* argv[])
}
/*
功能:
广度优先搜索
。
function:
广度优先搜索
.
参数:
parameter:
pGraph -- 图指针
*/
void
BreadthFirstSearch
(
Graph
*
pGraph
)
{
ArcNode
*
pArcNode
;
// 边(弧
)
节点指针
int
i
,
v
;
// 顶点序号
。从 0 开始计数。
int
nVisitCount
=
0
;
// 访问计数器
。
ArcNode
*
pArcNode
;
// 边(弧节点指针
int
i
,
v
;
// 顶点序号
.从 0 开始计数.
int
nVisitCount
=
0
;
// 访问计数器
.
//
// TODO:
在此添加代码
// TODO:
Add the code here
//
return
;
}
/*
功能:
function:
使用给定的数据初始化图的邻接表
参数:
parameter:
pGraph -- 图指针
*/
typedef
struct
VertexArrayEntry
{
const
char
*
name
;
// 顶点名称
。NULL 表示顶点序列结束。
int
VexIndex
[
MAX_VERTEX_NUM
];
// 与该顶点邻接的顶点序列
。-1 表示序列结束。
const
char
*
name
;
// 顶点名称
.NULL 表示顶点序列结束.
int
VexIndex
[
MAX_VERTEX_NUM
];
// 与该顶点邻接的顶点序列
.-1 表示序列结束.
}
VertexArrayEntry
;
const
VertexArrayEntry
VertexArray
[]
=
{
{
"V0"
,
{
2
,
5
,
1
,
-
1
}
},
...
...
@@ -131,10 +131,10 @@ void InitGraph(Graph* pGraph)
}
/*
功能:
function:
销毁图
参数:
parameter:
pGraph -- 图指针
*/
void
DeleteGraph
(
Graph
*
pGraph
)
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论