今天開始複習資料結構了,先從對陣列的操作開始。
心得:試數很關鍵,不回的時候就試一些數字,就出來了.#include #include #include struct arr //定義陣列的資料結構
;void init(struct arr * array,int len)//初始化陣列,使其擁有一塊確切的記憶體
bool is_empty(struct arr * array)//判斷陣列是否為空
bool is_full(struct arr * array)//判斷陣列是否已滿
void show_arr(struct arr * array)//顯示陣列中的數
}bool insert(struct arr * array,int pos,int val)//如果陣列滿了pos的值沒有在1~pos之間,也返回pos.
array->pbase[pos-1] = val;
(array->cnt)++;//最後使cnt+1
return
true;
}void sort_arr(struct arr * array)//氣泡排序}}
}void invert(struct arr * array)//最後乙個元素和第乙個元素互換
return;
}int main(void)
明天繼續鍊錶.
資料結構 佇列(C語言實現)
佇列 c語言實現 include include define queueisempty arg arg size 0 define queueisfull arg arg size arg capacity 判斷是否為空或為滿。巨集定義,函式調銷太大。佇列使用size和capacity顯式的判斷是...
資料結構C語言實現 ADT Triplet
declartion.h 型別宣告 define true 1 define false 0 define ok 1 define error 0 define infeasible 1 define overflow 2 define elemtype int typedef elemtype t...
資料結構 C語言實現串
include stdlib.h include stdio.h define true 1 define false 0 define maxlen 255 typedef int status typedef structstring 串的賦值 void strassign string s,c...