#include
#include
typedef struct qnode
{
int data;
struct qnode *next;
}qu;
typedef struct
{
qu *front;
qu *rear;
}li;
li *l,head;
void f(li *l)
{
l->front=(qu *)malloc(sizeof(qu));
if(!l->front)
printf("overflow!");
else
{
l->rear=l->front;
l->front->next=NULL;
printf("ok!");
}
}
void g(li *l,int
e) 进栈
{
qu *p;
if(l->front==l->rear) 要先插入第一个结点
l->front->data=e;
p=(qu *)malloc(sizeof(qu));
if(!p)
printf("overflow!");
p->data=e;
p->next=NULL;
l->rear->next=p;
l->rear=p;
}
r(li *l)
{
qu *p;
while(l->front!=l->rear)
{if(l->front->data==l->front->next->data)
l->front=l->front->next; 删除某个数即将头指针向后移
else
{
printf("%5d\n",l->front->data);
l->front=l->front->next;
}
}
printf("%5d\n",l->front->data);
}
void main()
{
int n,i,m;
l=&head;
f(l);
printf("how many nums do you want to put:");
scanf("%d",&n);
printf("the num is\n");
for(i=1;i<=n;i++)
{printf("%d:",i);
scanf("%d",&m);
g(l,m);
printf("\n");
}
r(l);
}_