#include<stdio.h>
enum{ERROR,OK}
typedef int KeyType;
typedef struct Qnode{
KeyType data;
struct Qnode*next;
}Qnode,*LinkQueue;
typedef struct{
int size;
Link:Queue rear;
}Queue;
int EnQueue(Queue*Q,KeyType new_elem)
{//元素elem入队列
QNode*p;
p=(Qnode)*malloc(sizeof(QNode));
if(!p)
{
return ERROR;
}
p->data=new_elem;
if(Q->rear){
p->next=Q->rear->next;
Q->rear->next=p;
}
else
p->next=p;
Q->rear=p;
Q->size++;
return OK;
}
int DeQueue(Queue*Q,KeyType*elem)
{//出队列
Qnode*p;
if(0==Q.size)
{
return ERROR;
}
p=Q->rear->next;
*elem=p->data;
Q->rear-next=p->next;
if(Q->size==1)
{
Q->rear=NULL;
free(p);
Q->size--;
return OK;
}
}
我最讨厌这样不能运行的代码