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

modify

上级 5528dd3f
......@@ -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)
{
......
#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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论