用C语言编写一算法将一链队列的元素依次取出,并打印这些元素值

来源:百度知道 编辑:UC知道 时间:2024/06/01 19:57:59
关于数据结构的。。

#define NULL 0
#include<stdio.h>
typedef struct point
{
int c;
struct point *next;
struct point *prior;
}node;
node * creat(node *head,int n)
{
node *p,*pt;
int i;
//p=(node *)malloc(sizeof(node));
//scanf("%d",&p->c);
scanf("%d",&head->c);
p=head;
pt=p;
i=1;
while(i<n)
{
p=(node *)malloc(sizeof(node));
scanf("%d",&p->c);
p->prior=pt;
pt->next=p;
pt=p;
i++;
}
p->next=NULL;
return head;
}
void bianli(node *head)
{
node *p;
p=head;
printf("\n");
while(p!=NULL)
{
printf("%d ",p->c);
p=p->next;
}
}
int main()
{
node *head;
int n;
head=(node *)malloc(sizeof(node));
printf("input the size of linklist:");
s