静态链表

建表

int MAXSIZE = 1000;
typedef struct 
{
    int data;
    int next;
}SNode;
SNode SD[MAXSIZE];

插入

void Insert_SList(int SL,int x,int i)
{
    int p,s;
    p = SL;j = 0;
    while(SD[p].next != -1 && j < i-1)
    {
        p = SD[p].next;
        j++;
    }
    
    if(j == i-1)
    {
        if(LV != -1)
        {
            t = LV;
            LV = SD[LV].next;
            SD[t].data = x;
            SD[t].next = SD[p].next;
            SD[p].next = t;
            return 1;
        }
        else {printf("存储池无节点");return 0; }
    }
    else{printf("插入的位置错误");return -1;}
}
原文地址:https://www.cnblogs.com/Cindy-Chan/p/11182017.html