组合提交代码(仅支持C++)
#include<iostream>
#include <stdio.h>
#include <malloc.h>
using namespace std;
typedef int ElemType;
typedef struct DNode //定义双链表结点类型
{
ElemType data;
struct DNode *prior; //指向前驱结点
struct DNode *next; //指向后继结点
} Dli
void InitList(Dli
{
L=(Dli
L->prior=L->next=NULL;
}
void DestroyList(Dli
{
Dli
while (p!=NULL)
{
free(pre);
pre=p;
p=pre->next;
}
free(pre);
}
void DispList(Dli
{
Dli
while (p!=NULL)
{
printf("%d ",p->data);
p=p->next;
}
printf("\n");
}
void CreateListR(Dli
//尾插法建双链表
{
/**************begin************/
/**************end************/
}
void reverse(Dli
{
/**************begin************/
/**************end************/
}
int main()
{
ElemType a[]={1,8,0,4,9,7,5,2,3,6};
Dli
CreateListR(L,a,10);
printf("L:");DispList(L);
printf("逆置\n");
reverse(L);
printf("L:");DispList(L);
DestroyList(L);
return 1;
}