靜態鍊錶的實現

2021-07-06 06:38:46 字數 1464 閱讀 7074

#include#include#define size 6      

//define struct of static list

typedef struct stlist

stlist;

//初始化靜態鍊錶分配空間大小為size個

stlist* initlist(stlist* tempptr)

//of for i

//initialize head and tail

tempptr->content[0]=-65535;

tempptr->exist[0]=1;

tempptr->content[1]=65535;

tempptr->exist[1]=1;

tempptr->next[0]=1;

tempptr->next[1]=-1;

return tempptr;

}//of initlist

//列印靜態鍊錶

void print(stlist* tempptr)

//of for i

//按照節點順序遍歷靜態鍊錶

printf("遍歷:\n");

while(1)

//of if

temp=tempptr->next[temp];

}//of while

}//of print

//把元素插入到靜態鍊錶當中

int insert(stlist* tempptr,int newelement)

//of if

}//of for i

for(i=0;i//把元素插入到靜態鍊錶中

靜態鍊錶的實現

用陣列來代替指標,來描述單鏈表 將陣列元素分成兩個資料域,data和cur。data用來存放資料元素,cur存放該元素的後繼在陣列中的下標 游標 游標實現法 線性表的靜態鍊錶儲存結構 define maxsize 1000 typedef struct component,staticlinklis...

靜態鍊錶的實現

2018 8 23 21 35 靜態鍊錶的實現 陣列中第乙個結點表示備用鍊錶的第乙個結點 陣列中最後乙個結點表示鍊錶的第乙個結點 當next域為0時均代表到了當前鍊錶的結尾,因此有兩個陣列單元 0與max 1 無法儲存目標資料 include define max 10 此時靜態鍊錶中只能儲存8個元...

靜態鍊錶實現

1 include stdio.h 2 struct nodelist 100 space 100 6 int listlen 0 7 void init 813 int free int p 14 18int malloc 1925 void add int p,int val 26 31int ...