#include <stdio.h>
#include<stdlib.h>
typedef struct twoNode {
int data;
twoNode* prior;
twoNode* next;
}DNode;
DNode* CreateNode(int i) {
DNode* node = (DNode*)malloc(sizeof(DNode));
node->prior = NULL;
node->next = NULL;
node->data = i;
return node;
}
void InsertFive(DNode* h){
for (int i = 1; i <= 5; i++) {
DNode* NewNode = CreateNode(i);
h->next = NewNode;
h = h->next;
}
}
void OutPut(DNode* h) {
h = h->next;
while (h)
{
if (h == NULL)
break;
printf("%d", h->data);
printf("\n");
h = h->next;
}
}
int main() {
DNode* head = (DNode*)malloc(sizeof(DNode));
DNode* h = head;
InsertFive(h);
InsertFive(h);
InsertFive(h);
OutPut(head);
}
运行结果