以下程序实现把单循环链表变成双循环链表:
#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include<time.h>
#include<conio.h>
#include<stdlib.h>
#define ElemType char
#define ARRAYSIZE 20
typedef struct LNode
{
ElemType data[20];
struct LNode *next,*prior;
}LNode,*LinkList;
int InitList(LinkList &L)//生成单循环链表
{
int i,j,t,flag,k=0;
LinkList p=NULL,q=NULL;
char str[ARRAYSIZE]={NULL};
L=(LinkList)malloc(sizeof(LNode));L->next=NULL;
strcpy(L->data,"-1");//链表头结点数据域值为 -1
srand((unsigned)time(NULL));
for(i=0;i<9;++i)//逆位序输入 n 个元素的值,建立带头结点的单链表 L
{
k=0;t=rand()%12;
p=(LinkList)malloc(sizeof(LNode));
for(j=0;j<3+t;++j)//数据域赋值为