#include
#include
#define error 0
#define ok 1
#define equal 1
#define overflow -1
#define list_init_size 100
#define listincrement 10
struct stustu[50];
typedef struct stu elemtype;
struct list
;typedef struct list list;
/*構造乙個空的線性表l*/
int init(list *l)
/*init */
/*返回l中資料元素的個數*/
int listlength(list *l)
/*若線性表l存在,1<=i<=l.length,用e返回l中第i個元素*/
void getelem(list l,int i,elemtype *e)
int equallist(elemtype *e1,elemtype *e2)
/*判斷元素的大小,通過元素的name欄位*/
int less_equallist(elemtype *e1,elemtype *e2)
/*若cur_e是l的元素,且不是第乙個,則用pre_e返回它的前驅*/
int priorelem(list *la,elemtype cur_e,elemtype *pre_e)
else}}
/*若cur_e是l的元素,且不是最後乙個,則用next_e返回它的後繼元素*/
int nextelem(list *la,elemtype cur_e,elemtype *next_e)
else}}
/*返回線性表l中第乙個與e滿足關係type的位序*/
int locateelem(list *la,elemtype e,int type)
return 0;
}/*從線性表l中刪除第i個元素,並且刪除的元素賦給e*/
int deleteelem(list *l,int i,elemtype e)
/*清空線性表l*/
void clearlist(list *l)
/*銷毀線性表l*/
int destroylist(list *l)
/*合併線性表la,lb到lc*/
void mergelist(list *la,list *lb,list *lc)
while(pa<=pa_last) *pc++=*pa++;
while(pb<=pb_last) *pc++=*pb++;
}void unionlist(list *la, list *lb)
/*listinsert before i */
main()
線性表 順序儲存C語言實現
定義 線性表是包含有限相同型別元素,除首元素外,其他元素只有乙個唯一前驅元素,除尾元素外,其他元素只有乙個後繼元素的線性結構表。均有2種儲存方式 順序儲存 鏈式儲存 資料結構定義 typedef struct tabletable 基本操作 table inittable t.length 0 re...
C語言 線性表的順序表示和實現
參考嚴蔚敏 吳偉民版 資料結構 c語言版 線性表的順序表示指的是用一組位址連續的儲存單元依次儲存線性表的資料元素。define list init size 100 線性表儲存空間的初始分配量 define listincrement 10 線性表儲存空間的分配增量 當因為插入新元素而儲存空間不足時...
線性表c語言實現
lineartable.h pragma once 線性表的實現 define maxsize 20 define ok 1 define error 2 typedef struct list list t 線性表初始化 void initlist list t list 根據下表查詢資料 int...