1,链队列
#include<stdio.h>
#include<malloc.h>
typedef struct node
{
int data;
struct node *next;
}node;
typedef struct
{
node *front;
node *rear;
}queue;
void inlit(queue &s)
{
s.front=s.rear=(node*)malloc(sizeof(node));
if(!s.front) return;
else
s.front->next=NULL;
return;
}
void enter(queue &s,int a)
{
node *p;
p=(node*)malloc(sizeof(node));
if(!p) return;
else
{
p->data=a;
p->next=NULL;
s.rear->next=p;
s.rear=p;
}
return;
}
int out(queue &s,int &c)
{
if(s.front==s.rear) return 0;
else
{
node *p;
p=s.front->next;
s.front->next=p->next;
c=p->data;
//有点用
if(s.rear==p)
s.rear=s.front;
/////////
free(p);
return 1;
}
}
void gettop(queue &s,int &b)
{
if(s.front==s.rear) return;
else
{