//队列的链式存储结构
typedef struct QNode{
int 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(1);
Q.front = NULL;
return OK;
}
void Judge(LinkQueue &Q){
if(Q.front == Q.rear)
printf("队列为空");
else
printf("队列不为空");
}
//入队
Status EnQueue(LinkQueue &Q,int e){
p = (QueuePtr)malloc(sizeof(QNode));
if(!p)
exit(1);
p->data = e;
p->next = NULL;
Q.rear->next = p;
Q.rear = p;
return OK;
}
//出队
Status Dequeue(LinkQueue &Q,int &e){
if(Q.front == Q.rear)
exit(1);
p = Q.front->next;
e = p->data;
Q.front->next = p->next;
if(Q.rear == p)
Q.rear = Q.front;
free(p);
return OK:
}
//模拟病人医院看病
void Hospital(int Closetime){
OpenForDay();
while (MoreEvent){
EventDrived(OccurTime.EventType);
switch(EventType){
case 'A':
CustomerArrived();
break;
case 'B':
CustomerDeparture();
break;
default:
Invalid();
}
}
}
typedef struct QNode{
int 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(1);
Q.front = NULL;
return OK;
}
void Judge(LinkQueue &Q){
if(Q.front == Q.rear)
printf("队列为空");
else
printf("队列不为空");
}
//入队
Status EnQueue(LinkQueue &Q,int e){
p = (QueuePtr)malloc(sizeof(QNode));
if(!p)
exit(1);
p->data = e;
p->next = NULL;
Q.rear->next = p;
Q.rear = p;
return OK;
}
//出队
Status Dequeue(LinkQueue &Q,int &e){
if(Q.front == Q.rear)
exit(1);
p = Q.front->next;
e = p->data;
Q.front->next = p->next;
if(Q.rear == p)
Q.rear = Q.front;
free(p);
return OK:
}
//模拟病人医院看病
void Hospital(int Closetime){
OpenForDay();
while (MoreEvent){
EventDrived(OccurTime.EventType);
switch(EventType){
case 'A':
CustomerArrived();
break;
case 'B':
CustomerDeparture();
break;
default:
Invalid();
}
}
}