循环单链表

2021-03-25  本文已影响0人  qianranow

#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
    int data;
    struct Node *next;
} LNode, *LinkList;

/*
 * 若需要经常对表头或表尾进行操作,可以让l指向尾结点
 */
int InitList() {
    LNode *l = (LNode *)malloc(sizeof(LNode));
    if (l == NULL) return -1;
    l->next = l;
    return 1;
}

int Empty(LinkList l) {
    if (l->next == l) return 1;
    else return -1;
}

int isTail(LinkList l, LNode *p) {
    if (p->next == l) return 1;
    else return -1;
}

上一篇 下一篇

猜你喜欢

热点阅读