创建两个循环链表,并将这两个循环链表连接成为一个循环链表的示例程序,将以下代码保存到一个源文件中:combine_two_circular_linked_list.c, 如下所示 -
#include
#include
struct node {
int data;
struct node *next;
};
struct node *even = NULL;
struct node *odd = NULL;
struct node *list = NULL;
//Create Linked List
void insert(int data) {
// Allocate memory for new node;
struct node *link = (struct node*) malloc(sizeof(struct node));
struct node *current;
link->data = data;
link->next = NULL;
if (data % 2 == 0) {
if (even == NULL) {
even = link;
even->next = link;
return;
}
else {
current = even;
while (current->next != even)
current = current-