📄 queue.h
字号:
#include "HEAD.H"
struct Node{
char e;
struct Node* Next;
};
struct Queue {
struct Node* head;
struct Node* buttom;
/*char e;
struct Queue* Next;*/
};
/*Status IsQEmpty(struct Queue *q){
if (q->Next==q && q->e=='\0') return TRUE; else return FALSE;
}*/
struct Queue *InitQ(struct Queue *q){
q->head=q->buttom=(struct Node*)malloc(sizeof(struct Node));
if(!q->head) msg("Init Queue error");
q->head->Next=NULL;
/*q=(struct Queue *)malloc(sizeof(struct Queue));
q->Next=q;
//q->Top=q->Next=q;
printf("%d\n",q->e );*/
msg("Init Queue Seccuss");
return q;
}
struct Queue *DestQ(struct Queue *q){
/*if (q==q->Next && q->e=="\0"){
free(q);
msg("Destory Queue Seccuss");}
q->Next=q;
q->e='\0';*/
/*free(q);*/
while(q->head){
q->buttom=q->head->Next;
free(q->head);
q->head=q->buttom;
}
msg("Destory Queue Seccuss");
return q;
}
struct Queue *InsQ(struct Queue *q,char c){
/* if (q->e=='\0') {
q->e=c;
printf("%c\n-------",q->e );
} else{
struct Queue p;
// p=(struct Queue *)malloc(sizeof(struct Queue));
p.e=c;
q->Next=&p;
p.Next=q;}*/
struct Node* p;
p=(struct Node *)malloc(sizeof(struct Node));
if (!p) msg("Error :Insert to Queue");
else{
p->e=c;
p->Next=NULL;
q->buttom->Next=p;
q->buttom=p;
msg("Insert to Queue Seccuss");
}
return q;
}
char DelQ(struct Queue *q){
/* if (IsQEmpty(q))
msg("Error: Queue is Empty");
else
q->Next=q->Next->Next;*/
struct Node* p;
char e;
if(q->head==q->buttom) msg("Error :Del to Queue,Null");
p=q->head->Next;
e=p->e ;
q->head->Next=p->Next;
if (q->buttom==p)q->buttom=q->head;
free(p);
return e;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -