typedef struct node{
char data;
node *next;
} NODE;
NODE *front=NULL, *rear=NULL;
void intoQueue(char x)//入队
{
NODE *p=(NODE *)malloc(sizeof(NODE));//分配空间和赋值
p->data=x;
p->next=NULL;
if(front==NULL)//空队列
{
front=p;
}
else
{
rear->next=p;
}
rear=p;
}
int outQueue(char *p_y)//出队
{
NODE *p=(NODE *)malloc(sizeof(NODE));
if(front==NULL) return -1;
p=front;
front=front->next;
*p_y=p->data;
free(p);
return 0;
}
int isEmpty()
{
if(*front==NULL) return 0;
else return-1;
}
posted on 2006-09-24 19:45
创建更好的解决方案 阅读(566)
评论(0) 编辑 收藏 引用