数据结构之---c语言实现循环单链表操作

//=========杨鑫========================//
//循环单链表的实现
#include 
#include 
 
typedef int ElemType;
//定义结点类型 
typedef struct Node
{
    ElemType data;                
    struct Node *next;            
}Node,*LinkedList;
int count = 0;


//1、单循环链表的初始化
LinkedList init_circular_linkedlist()
{
    Node *L;
    L = (Node *)malloc(sizeof(Node));  
    if(L == NULL)                        
        printf("申请内存空间失败\n");
    L->next = L;                    
}



//2、循环单链表的建立
LinkedList creat_circular_linkedlist()
{
    Node *L;
    L = (Node *)malloc(sizeof(Node));   
    L->next = L;                  	 
    Node *r;
    r = L;                          	  
    ElemType x;                         
    while(scanf("%d",&x))
    {
		if(x == 0)
			break;
		count++;
        Node *p;
        p = (Node *)malloc(sizeof(Node));    
        p->data = x;                    	  
        r->next = p;                		  
        r = p

你可能感兴趣的:(C,&&,C++,数据结构,算法)