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

modify

上级 5528dd3f
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
/* /*
功能: function:
初始化队列。 Initialization queue.
参数: parameter:
pQ -- 队列指针 pQ -- Pointer to a queue
*/ */
void InitQueue(Queue* pQ) void InitQueue(Queue* pQ)
{ {
...@@ -15,21 +15,21 @@ void InitQueue(Queue* pQ) ...@@ -15,21 +15,21 @@ void InitQueue(Queue* pQ)
} }
/* /*
功能: function:
将元素插入队尾。 Insert the element at the end of the queue.
参数: parameter:
pQ -- 队列指针 pQ -- Pointer to a queue
Elem -- 入队的元素 Elem -- Elements of enrolling
返回值: returned value:
如果插入成功返回入队元素的值。 Returns the value of the enqueued element if the insert is successful.
如果插入失败返回 -1。 Returns -1 if insert fails.
*/ */
int EnQueue(Queue* pQ, int Elem) int EnQueue(Queue* pQ, int Elem)
{ {
// //
// 队列满,入队失败。 // Queue full, fail to join.
// //
if(MAX_QUEUE_LENGTH == pQ->length) if(MAX_QUEUE_LENGTH == pQ->length)
return -1; return -1;
...@@ -42,22 +42,22 @@ int EnQueue(Queue* pQ, int Elem) ...@@ -42,22 +42,22 @@ int EnQueue(Queue* pQ, int Elem)
} }
/* /*
功能: function:
将队首元素出队 Remove the first element from the team
参数: parameter:
pQ -- 队列指针 pQ -- Pointer to a queue
返回值: returned value:
如果出队成功返回出队元素的值。 Returns the value of the queued element if queued successfully.
如果出队失败返回 -1。 Returns -1 if dequeuing fails.
*/ */
int DeQueue(Queue* pQ) int DeQueue(Queue* pQ)
{ {
int Elem; int Elem;
// //
// 队列空,出队失败 // Queue empty, dequeue failed
// //
if(QueueEmpty(pQ)) if(QueueEmpty(pQ))
return -1; return -1;
...@@ -70,15 +70,15 @@ int DeQueue(Queue* pQ) ...@@ -70,15 +70,15 @@ int DeQueue(Queue* pQ)
} }
/* /*
功能: function:
判断队列是否为空。 Determines if the queue is empty.
参数: parameter:
pQ -- 队列指针 pQ -- Pointer to a queue
返回值: returned value:
如果队列空返回 1(真) Returns 1 if the queue is empty.
如果队列非空返回 0(假) Returns 0 if the queue is non-empty.
*/ */
int QueueEmpty(Queue* pQ) int QueueEmpty(Queue* pQ)
{ {
......
#include "Graph.h" #include "Graph.h"
int visited[MAX_VERTEX_NUM]; // 顶点访问标志数组。0 表示未访问;大于 0 表示访问的先后次序。 int visited[MAX_VERTEX_NUM]; // 顶点访问标志数组.0 表示未访问;大于 0 表示访问的先后次序.
Queue queue; // 队列 Queue queue; // 队列
int main(int argc, char* argv[]) int main(int argc, char* argv[])
...@@ -52,35 +52,35 @@ int main(int argc, char* argv[]) ...@@ -52,35 +52,35 @@ int main(int argc, char* argv[])
} }
/* /*
功能: function:
广度优先搜索 广度优先搜索.
参数: parameter:
pGraph -- 图指针 pGraph -- 图指针
*/ */
void BreadthFirstSearch(Graph* pGraph) void BreadthFirstSearch(Graph* pGraph)
{ {
ArcNode* pArcNode; // 边(弧节点指针 ArcNode* pArcNode; // 边(弧节点指针
int i, v; // 顶点序号。从 0 开始计数。 int i, v; // 顶点序号.从 0 开始计数.
int nVisitCount = 0; // 访问计数器 int nVisitCount = 0; // 访问计数器.
// //
// TODO: 在此添加代码 // TODO: Add the code here
// //
return; return;
} }
/* /*
功能: function:
使用给定的数据初始化图的邻接表 使用给定的数据初始化图的邻接表
参数: parameter:
pGraph -- 图指针 pGraph -- 图指针
*/ */
typedef struct VertexArrayEntry { typedef struct VertexArrayEntry {
const char* name; // 顶点名称。NULL 表示顶点序列结束。 const char* name; // 顶点名称.NULL 表示顶点序列结束.
int VexIndex[MAX_VERTEX_NUM]; // 与该顶点邻接的顶点序列。-1 表示序列结束。 int VexIndex[MAX_VERTEX_NUM]; // 与该顶点邻接的顶点序列.-1 表示序列结束.
}VertexArrayEntry; }VertexArrayEntry;
const VertexArrayEntry VertexArray[] = { const VertexArrayEntry VertexArray[] = {
{ "V0", {2, 5, 1, -1} }, { "V0", {2, 5, 1, -1} },
...@@ -131,10 +131,10 @@ void InitGraph(Graph* pGraph) ...@@ -131,10 +131,10 @@ void InitGraph(Graph* pGraph)
} }
/* /*
功能: function:
销毁图 销毁图
参数: parameter:
pGraph -- 图指针 pGraph -- 图指针
*/ */
void DeleteGraph(Graph* pGraph) void DeleteGraph(Graph* pGraph)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论