请诸位帮我看看下面的程序是不是双向链表:谢谢!
#include<stdio.h>
#include<stdlib.h>
typedef struct DuLNode{
int data;
struct DuLNode *prior; //指向先前元素的指针
struct DuLNode *next; //指向后继元素的指针
}DuLnode,*DuLinkList;
DuLinkList CreateList(DuLinkList L,int value);
void Output(DuLinkList L);
int main(void)
{
DuLinkList L=NULL;
int i,n,value;
printf("Please input n: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&value);
L=CreateList(L,value);
Output(L);
}
return 0;
}
DuLinkList CreateList(DuLinkList L,int value)
{
DuLinkList newPtr,previousPtr,currentPtr;
newPtr=(DuLinkList)malloc(sizeof(DuLnode));
if(newPtr!=NULL)
{
newPtr->data=value;
newPtr->next=NULL;
previousPtr=NULL;
currentPtr=L;
while(currentPtr && currentPtr->data < value)
{
previousPtr=currentPtr;
currentPtr=currentPtr->next;
}
if(previousPtr==NULL) //当是空表情况
{
newPtr->prior=L;
newPtr->next=L;
L=newPtr;
}
else if(currentPtr) //在表中间插入
{
previousPtr->next=newPtr;
newPtr->prior=previousPtr;
currentPtr->prior=newPtr;
newPtr->next=currentPtr;
}
else if(currentPtr==NULL) //在表尾插入
{
previousPtr->next=newPtr;
newPtr->prior=previousPtr;
newPtr->next=NULL;
}
}
else
printf("Dynamic malloc memory failure.\n");
return L;
}
void Output(DuLinkList L) //输出链表函数
{
while(L)
{
printf("%d->",L->data);
L=L->next;
}
printf("NULL\n");
}