#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct Node
{
int data;
struct Node* next;
}Node,*LinkList;//LinkList是表头
void InitLinkList(LinkList* CL)
{
*CL = (LinkList)malloc(sizeof(Node));
(*CL)->next = *CL;
}
void CreateCLinkList(LinkList CL)
{//CL是带头结点的空循环链表
Node* rear, * s;//rear是动态指针
char c;
rear = CL;
c = getchar();
while (c != '$')
{
s = (Node*)malloc(sizeof(Node));
s->data = c;
rear->next = s;
rear = s;
c = getchar();
}
rear->next = CL;
}
创建一个有环链表
最新推荐文章于 2024-10-20 16:12:29 发布