数据结构::线性队列
数据结构::线性队列
#include <iostream> using namespace std; #define MaxSize 10 /*//链栈 typedef struct Linknode{ int data; struct Linknode *next; }*LiStack; */ //队列 typedef struct { int data[MaxSize]; int front; int rear; }SqQueue; void InitQueue(SqQueue &Q) { Q.front =0; Q.rear=0; } bool QueueEmpty(SqQueue Q) { if(Q.front == Q.rear) return true; else return false; } bool EnQueue(SqQueue &Q,int x) { if((Q.rear+1)%MaxSize == Q.front) return false; Q.data[Q.rear]=x; Q.rear = (Q.rear+1)%MaxSize; return true; } bool DeQueue(SqQueue &Q,int &x) { if(Q.front==Q.rear) return false; x=Q.data[Q.front]; Q.front=(Q.front+1)%MaxSize; return true; } bool GetHead(SqQueue &Q,int &x) { if(Q.front==Q.rear) return false; x=Q.data[Q.front]; return true; } int main() { SqQueue Q; return 0; }
相关推荐
koushr 2020-11-12
zhangxiafll 2020-11-13
kikaylee 2020-10-31
范范 2020-10-28
MILemon 2020-10-22
hugebawu 2020-10-12
LauraRan 2020-09-28
shenwenjie 2020-09-24
omyrobin 2020-09-23
guangcheng 2020-09-22
qiangde 2020-09-13
hanyujianke 2020-08-18
晨曦之星 2020-08-14
xiesheng 2020-08-06
KAIrving 2020-08-02
xiesheng 2020-08-02
范范 2020-07-30
chenfei0 2020-07-30