資料結構學習筆記(一) 順序表

2021-07-14 08:37:20 字數 784 閱讀 3155

一般來說,由於順序表結點的位序從1開始,而c語言中向量的下標從0開始,若從下標為1的向量元素開始使用,使結點的位序和向量的下標一致,則處理會簡單一些,下標為0的元素不用或用作其它用途。

#include 

#include

using

namespace

std;

#define maxsize 1024

//結構型別定義

typedef

int datatype;

typedef

structsequenlist;

sequenlist*l;

//初始化

sequenlist*initlist()

//插入結點

int insert(sequenlist*l,datatype x,int i)

else

if(i<1||i>l->last+1)

else

}//刪除結點

int delete(sequenlist*l,int i)

else

}//按值定位

int locate(sequenlist*l,datatype x)

return0;}

//就地逆置

int invert(sequenlist*l)

return1;}

//輸出順序表

int show(sequenlist* l)

//測試

int main()

資料結構學習筆記1順序表

初始化需要定義的三個要素 c語言 實現 typedef struct table table c語言 實現 table inittable t.length 0 t.size size return t c語言 實現 table addtable table t,int elem,int add i...

C 資料結構學習一 順序表

順序表模板類 ifndef sequential list hxx define sequential list hxx using std cout using std endl const int maxsize 100 順序表陣列最大值 template class seqlist 定義模板類...

C語言資料結構學習 順序表

include include define size 5 typedef struct sequencetable sequencetable brief 初始化順序表 return sequencetable sequencetable inittable st.length 0 st.size...