//循环队列代码默写 #define Maxsize 50 typedef struct{ //Elemtype data[Maxsize]; //int front,rear; }sqQueue; //circle queue viod InitQueue(/*sqQueue &Q*/){ //Q.front=Q.rear=0; } bool isempty(/*sqQueue Q*/){ /*if(Q.rear==Q.front) return ture; else return flase;*/ } bool enqueue(/*sqQueue &Q,Elemtype x*/){ /*if((Q.rear+1)%Maxsize==Q.front) return flase; data[Q.rear]=x; Q.rear=(Q.rear+1)%Maxsize; return ture;*/ } bool dequeue(/*sqQueue &Q,Elemtype &x*/){ /*if(Q.rear==Q.front) return false; x=data[Q.front]; Q.front=(Q.front+1)%Maxsize; return ture;*/ }
//链式队列代码默写 typedef struct { /*Elemtype data; struct Linknode *next;*/ }Linknode; typedef struct { //Linknode *rear,*front; }LinkQueue; void initqueue(/*Linknode Q*/){ /*Q.rear=Q.front=(Linknode *)malloc(sizeof(Linknode)); Q.front->next=null;*/ } bool isempty(/*LinkQueue Q*/){ /*if(Q.rear==Q.front) return ture; else return false;*/ } void enqueue(/*LinkQueue &Q,Elemtype x*/){ /*Linknode *s=(Linknode *)malloc(sizeof(Linknode)); s->data=x; Q.rear->next=s; Q.rear=s; s->next=null;*/ } bool dequeue(/*LinkQueue &Q,Elemtypedef &x*/){ /*if(Q.rear==Q.front) return false; Linknode *s=Q.front->next; x=s->data; Q.front->next=s->next; if(s==Q.rear) Q.front==Q.rear; free(s); return ture;*/ } ```c