list.c

来自「一些ARM的源程序」· C语言 代码 · 共 42 行

C
42
字号
typedef struct List {
    struct List *next;
    void *data;
} List;

int length(List *l)
{
    int n;

    n = 0;
    while (l) {
        l = l->next;
        n++;
    }
    return n;
}

List *reverse(List *l)
{
    List *new_l, *t;

    new_l = 0;
    while (l) {
        t = l->next;
        l->next = new_l;
        new_l = l;
        l = t;
    }
    return new_l;
}

List *conc(List *a, List *b)
{
    List *l, **l_p, *t;

    l = a;
    l_p = &l;
    while (t = *l_p) l_p = &(t->next);
    *l_p = b;
    return a;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?