線性表的初始化、查詢、插入、刪除操作的c語言版
#include #define maxsize 20 //線性表的最大長度為20
typedef int elemtype; //線性表中的元素型別設為int型
typedef struct //定義線性表的結構
sqlist;
int initlist(sqlist *l)
int getelem(sqlist l,int i,elemtype *e) //獲取線性表l中第i個位置的元素,並用e返回該元素的數值
l->data[i-1]=e;
l->length++;
return 1;
}int listdelete(sqlist *l,int i,elemtype *e)
} l->length--;
return 1;
}
線性表操作
include stdio.h define maxsize 20 define overflow 1 define ok 1 define error 1 void init seqlist int length pointer 構造乙個空的線性表 int insert last int elem...
線性表操作
大概實現的功能 1 建立線性表類。線性表的儲存結構使用鍊錶。2 提供操作 自表首插入元素 刪除指定元素 搜尋表中是否有指定元素 輸出鍊錶。3 接收鍵盤錄入的一系列整數 例10,25,8,33,60 作為節點的元素值,建立鍊錶。輸出鍊錶內容。4 輸入乙個整數 例33 在鍊錶中進行搜尋,輸出其在鍊錶中的...
線性表操作
include using namespace std define maxsize 10000 typedef struct sqlist 在上述定義後,可以通過變數定義語句 sqlist l 將l定義為sqlist型別的變數,便可以利用 l.data i 1 來訪問表中位置 序號為i 的資料 i...