没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
#include<iostream>
#include<stdlib.h>
#include<string>
#include<io.h>
#include<math.h>
#include<process.h>
#include<stdio.h>
using namespace std;
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef int Boolean;
typedef char qelemtype;
typedef struct qnode
{
qelemtype data;
struct qnode *next;
}qnode, *queueptr;
typedef struct
{
queueptr front;
queueptr rear;
} linkqueue;
Status initqueue(linkqueue &q)
{
q.front=q.rear=(queueptr)malloc(sizeof(qnode));
#include<stdlib.h>
#include<string>
#include<io.h>
#include<math.h>
#include<process.h>
#include<stdio.h>
using namespace std;
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
typedef int Status;
typedef int Boolean;
typedef char qelemtype;
typedef struct qnode
{
qelemtype data;
struct qnode *next;
}qnode, *queueptr;
typedef struct
{
queueptr front;
queueptr rear;
} linkqueue;
Status initqueue(linkqueue &q)
{
q.front=q.rear=(queueptr)malloc(sizeof(qnode));
if(!q.front) exit(OVERFLOW);
q.front->next=NULL;
return OK;
}
Status destroyqueue(linkqueue &q)
{
while(q.front)
{
q.rear=q.front->next;
free(q.front);
q.front=q.rear;
}
return OK;
}
Status enqueue(linkqueue &q,qelemtype e)
{
queueptr p;
p=(queueptr)malloc(sizeof(qnode));
if(!p)
exit(OVERFLOW);
p->data=e;
p->next=NULL;
q.rear->next=p;
q.rear=p;
return OK;
}
Status dequeue(linkqueue &q,qelemtype &e)
{
queueptr p;
if(q.front==q.rear) return ERROR;
q.front->next=NULL;
return OK;
}
Status destroyqueue(linkqueue &q)
{
while(q.front)
{
q.rear=q.front->next;
free(q.front);
q.front=q.rear;
}
return OK;
}
Status enqueue(linkqueue &q,qelemtype e)
{
queueptr p;
p=(queueptr)malloc(sizeof(qnode));
if(!p)
exit(OVERFLOW);
p->data=e;
p->next=NULL;
q.rear->next=p;
q.rear=p;
return OK;
}
Status dequeue(linkqueue &q,qelemtype &e)
{
queueptr p;
if(q.front==q.rear) return ERROR;
剩余10页未读,继续阅读
资源评论
越晓亮
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功