04線性表順序顯示

2021-10-14 02:14:56 字數 493 閱讀 1842

線性表的順序顯示

1順序表的定義:順序儲存的線性表

2、順序儲存描述**

#define maxsize 50 //定義線性表的最大長度

typedef structsqlist; //順序表型別定義

2、順序表上操作的實現

1、插入操作:在順序表第i個位置插入元素,成功返回true,失敗返回false。

bool listinsert(sqlist &l,int i,elemtype e)

l.data[i-1]=e; //順序表第i個位置放入e

l.length++; //線性表長度加1

return true;

}複雜度分析:時間複雜度o(n),

2、刪除操作:刪除第i個元素,成功返回true,並將刪除的元素用變數e返回,失敗返回false

bool listdelete(sqlist &l,int i,elemtype &e)

複雜度分析:時間複雜度o(n)

順序線性表

sequential linear list this file define the ds of sequential linear list s basic operation,it includes linear list insert,delete,initial,and sort oper...

順序線性表

include int const maxsize 100 typedef int element typedef struct list element list get index value list int int main 函式 初始化線性表 void list init list ls ...

順序線性表

define true 1 define false 0 define ok 1 define error 0 define infeasible 1 define overflow 2 define list init size 100 define list increment 10 typed...