list.c

来自「多目标遗传算法的程序」· C语言 代码 · 共 49 行

C
49
字号
/* A custom doubly linked list implemenation */# include <stdio.h># include <stdlib.h># include <math.h># include "global.h"# include "rand.h"/* Insert an element X into the list at location specified by NODE */void insert (list *node, int x){    list *temp;    if (node==NULL)    {        printf("\n Error!! asked to enter after a NULL pointer, hence exiting \n");        exit(1);    }    temp = (list *)malloc(sizeof(list));    temp->index = x;    temp->child = node->child;    temp->parent = node;    if (node->child != NULL)    {        node->child->parent = temp;    }    node->child = temp;    return;}/* Delete the node NODE from the list */list* del (list *node){    list *temp;    if (node==NULL)    {        printf("\n Error!! asked to delete a NULL pointer, hence exiting \n");        exit(1);    }    temp = node->parent;    temp->child = node->child;    if (temp->child!=NULL)    {        temp->child->parent = temp;    }    free (node);    return (temp);}

⌨️ 快捷键说明

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