#include<stdio.h>
#include<stdlib.h>
#define TRUE 1;
#define FALSE 0;
typedef struct node
{
int date;
struct node *next;
}LQ;
typedef struct
{
LQ *front;
LQ *rear;
}Lq;
void inqu(Lq *Q)//初始化
{
Q->front=(LQ *)malloc(sizeof(LQ));
if(Q->front!=NULL)
{
Q->rear=Q->front;
Q->front->next=NULL;
}
}
void enter(Lq *Q)//进
{
int x;
printf("请输入x的值:");
scanf("%d",&x);
LQ *p;
while(x!=0)
{
p=(LQ *)malloc(sizeof(LQ));
p->date=x;
Q->rear->next=p;
Q->rear=p;
scanf("%d",&x);
}
p->next=NULL;
}
void delet(Lq *Q)//出
{
LQ *p;
if(Q->front==Q->rear)
printf("出栈错误!!!");
p=Q->front->next;
Q->front->next=p->next;
if(Q->rear==p)
Q->rear=Q->front;
}
void prin(Lq *Q)
{
LQ *s=Q->front->next;
while(s!=NULL)
{
printf("%d ",s->date);
s=s->next;
}
printf("\n");
}
int main()
{
Lq Q;
inqu(&Q);
enter(&Q);
delet(&Q);
prin(&Q);
return 0;
}
#include<stdlib.h>
#define TRUE 1;
#define FALSE 0;
typedef struct node
{
int date;
struct node *next;
}LQ;
typedef struct
{
LQ *front;
LQ *rear;
}Lq;
void inqu(Lq *Q)//初始化
{
Q->front=(LQ *)malloc(sizeof(LQ));
if(Q->front!=NULL)
{
Q->rear=Q->front;
Q->front->next=NULL;
}
}
void enter(Lq *Q)//进
{
int x;
printf("请输入x的值:");
scanf("%d",&x);
LQ *p;
while(x!=0)
{
p=(LQ *)malloc(sizeof(LQ));
p->date=x;
Q->rear->next=p;
Q->rear=p;
scanf("%d",&x);
}
p->next=NULL;
}
void delet(Lq *Q)//出
{
LQ *p;
if(Q->front==Q->rear)
printf("出栈错误!!!");
p=Q->front->next;
Q->front->next=p->next;
if(Q->rear==p)
Q->rear=Q->front;
}
void prin(Lq *Q)
{
LQ *s=Q->front->next;
while(s!=NULL)
{
printf("%d ",s->date);
s=s->next;
}
printf("\n");
}
int main()
{
Lq Q;
inqu(&Q);
enter(&Q);
delet(&Q);
prin(&Q);
return 0;
}