课题设计 停车场车辆管理系统C语言版数据结构Word文档下载推荐.docx
- 文档编号:15727728
- 上传时间:2022-11-15
- 格式:DOCX
- 页数:13
- 大小:18.83KB
课题设计 停车场车辆管理系统C语言版数据结构Word文档下载推荐.docx
《课题设计 停车场车辆管理系统C语言版数据结构Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《课题设计 停车场车辆管理系统C语言版数据结构Word文档下载推荐.docx(13页珍藏版)》请在冰豆网上搜索。
}Car;
typedefCarUser;
//用户自定义类型
#defineFEIYONG0.05//停车费用单价
#defineMAXSIZE5//停车场容量
//--------------系统库函数------------------
#include"
stdlib.h"
//--------------通用变量、常量、类型声明------------------
#defineTRUE1
#defineFALSE0
#defineOK1
#defineERROR0
#defineOVERFLOW-2
typedefintStatus;
typedefUserSElemType;
//---------------存储表示---------------------
#defineSTACK_INIT_SIZE100
#defineSTACKINCREMENT10
typedefstruct{
SElemType*base;
SElemType*top;
intstacksize;
}SqStack;
//---------------函数原型---------------------
//StatusInitStack(SqStack&
S);
//构造空栈
//StatusDestroyStack(SqStack&
//销毁栈S
//StatusClearStack(SqStack&
//置空
//StatusStackEmpty(SqStackS);
//判空;
空:
TRUE,不空:
FALSE。
//intStackLength(SqStackS);
//返回S的元素的个数,即栈的长度。
//StatusGetTop(SqStackS,SElemType&
e);
//若栈不空,则用e返回S的栈顶元素,并返回OK;
否则返回ERROR。
//StatusPush(SqStack&
S,SElemTypee);
//插入元素e为新的栈顶元素
//StatusPop(SqStack&
S,SElemType&
//若栈不空,则删除S的栈顶元素,用e返回其值,并返回OK;
//StatusStackTraverse(SqStackS,Status(*visit)());
//从栈底到栈顶依次对栈中每个元素调用函数visit()。
一旦visit()失败,则操作失败。
//---------------基本操作---------------------
StatusInitStack(SqStack&
S){
S.base=(SElemType*)malloc(STACK_INIT_SIZE*sizeof(SElemType));
if(!
S.base)exit(OVERFLOW);
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
returnOK;
}//InitStack
StatusDestroyStack(SqStack&
S){
free(S.base);
}//DestroyStack
StatusClearStack(SqStack&
}//ClearStack
StatusStackEmpty(SqStackS){
if(S.top==S.base)returnTRUE;
elsereturnFALSE;
}//QueueEmpty
intStackLength(SqStackS){
returnS.top-S.base;
}
StatusGetTop(SqStackS,SElemType&
e){
if(S.top==S.base)returnERROR;
e=*(S.top-1);
}//GetTop
StatusPush(SqStack&
S,SElemTypee){
if(S.top-S.base>
=S.stacksize){//栈满,追加存储空间
S.base=(SElemType*)realloc(S.base,
(S.stacksize+STACKINCREMENT)*sizeof(SElemType));
if(!
//存储分配失败
S.top=S.base+S.stacksize;
S.stacksize+=STACKINCREMENT;
}
*S.top++=e;
}//Push
StatusPop(SqStack&
e=*--S.top;
}//Pop
StatusStackTraverse(SqStackS){//,Status(*visit)()){
//从栈底到栈顶依次对栈S中每个元素调用函数visit()。
for(SElemType*p=S.base;
p<
S.top;
p++)
printf("
%d\n"
p->
number);
}//StackTraverse
typedefUserQElemType;
typedefstructQNode{
QElemTypedata;
structQNode*next;
}QNode,*QueuePtr;
QueuePtrfront;
QueuePtrrear;
}LinkQueue;
//StatusInitQueue(LinkQueue&
Q);
//构造空队列Q
//StatusDestroyQueue(LinkQueue&
//销毁队列Q
//StatusClearQueue(LinkQueue&
//StatusQueueEmpty(LinkQueueQ);
//intQueueLength(LinkQueueQ);
//返回S的元素的个数,即队列的长度。
//StatusGetHead(LinkQueueQ,QElemType&
//若队列不空,则用e返回S的队头元素,并返回OK;
//StatusEnQueue(LinkQueue&
Q,QElemTypee);
//插入元素e为新的队尾元素
//StatusDeQueue(LinkQueue&
Q,QElemType&
//若队列不空,则删除Q的队头元素,用e返回其值,并返回OK;
//StatusQueueTraverse(LinkQueueQ,Status(*visit)());
//从队头到队尾依次对队列Q中每个元素调用函数visit()。
StatusInitQueue(LinkQueue&
Q){
Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode));
Q.front)exit(OVERFLOW);
Q.front->
next=NULL;
}//InitQueue
StatusDestroyQueue(LinkQueue&
while(Q.front){
Q.rear=Q.front->
next;
free(Q.front);
Q.front=Q.rear;
}//DestroyQueue
StatusQueueEmpty(LinkQueueQ){
if(Q.front==Q.rear)returnTRUE;
//返回Q的元素的个数,即队列的长度。
StatusGetHead(LinkQueueQ,QElemType&
//若队列不空,则用e返回Q的队头元素,并返回OK;
if(Q.front==Q.rear)returnERROR;
e=Q.front->
next->
data;
}//GetHead
StatusEnQueue(LinkQueue&
Q,QElemTypee){
QueuePtrp;
p=(QueuePtr)malloc(sizeof(QNode));
p)exit(OVERFLOW);
p->
data=e;
Q.rear->
next=
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课题设计 停车场车辆管理系统C语言版数据结构 课题 设计 停车场 车辆 管理 系统 语言版 数据结构
![提示](https://static.bdocx.com/images/bang_tan.gif)