資料結構原始碼筆記(C語言) 集合的位向量表示

2021-10-08 21:57:17 字數 3428 閱讀 4933

/*bitset.c*/

/*集合的位向量表示:函式實現*/

#include

#include

#define supernum 20

#define sonnum 8

/*集合的位向量表示:型別和介面定義*/

typedef

struct

bitset;

/*空集合的建立*/

bitset * createemptyset (

int n)

}return

null;}

/*將值為index的元素插入集合s*/

int insert (bitset * s,

int index)

return0;

}/*將值為index的元素從集合s中刪除*/

intdelete

(bitset * s,

int index)

return0;

}/*判斷整數index的元素是否屬於集合s*/

intmember

(bitset * s,

int index)

/*集合與集合的並*/

intunion_set

(bitset *s0,bitset *s1,bitset *s2)

/*集合與集合的交*/

intintersection

(bitset * s0, bitset * s1, bitset * s2)

/*集合與集合的差*/

intdifference

(bitset * s0, bitset * s1, bitset * s2)

void

display

(bitset *s,

int* super_set)

printf

("}\n\n");

}int

main()

;int subset[sonnum]=;

int othersubset[4]

=;/*空集合的建立*/

s0=createemptyset (supernum)

; s1=createemptyset (supernum)

; s2=createemptyset (supernum)

; s3=createemptyset (supernum)

; s4=createemptyset (supernum)

;//將subset集合存放到儲存結構的陣列array中

for(i=

0;i) j++;}

;

j=0;

}printf

("集合s0=");

display

(s0,superset)

;/*將值為index的元素從集合s中刪除*/

printf

("刪除元素後,集合s0=");

delete

(s0,3)

;display

(s0,superset)

;/*判斷整數index的元素是否屬於集合s*/if(

member

(s0,11)

)printf

("判斷11是該集合的元素\n");

else

printf

("判斷11不是該集合的元素\n");

//建立另外乙個集合s1

j=0;

for(i=

0;i) j++;}

;

j=0;

}printf

("集合s1=");

display

(s1,superset)

;/*集合與集合的並*/

union_set (s0, s1, s2)

;printf

("s0,s1做並後,s2=");

display

(s2,superset)

;/*集合與集合的交*/

intersection

(s0, s1, s3)

;printf

("s0,s1做交後,s3=");

display

(s3,superset)

;/*集合與集合的差*/

difference

(s0, s1, s4)

;printf

("s0,s1做差後,s4=");

display

(s4,superset)

;return0;

}

資料結構原始碼筆記(c語言描述)彙總:

資料結構原始碼筆記(c語言):英文單詞按字典序排序的基數排序

資料結構原始碼筆記(c語言):直接插入排序

資料結構原始碼筆記(c語言):直接選擇排序

資料結構原始碼筆記(c語言):置換-選擇演算法

資料結構原始碼筆記(c語言):huffman樹字元編碼

資料結構原始碼筆記(c語言):josephus問題之順序表

資料結構原始碼筆記(c語言):josephus問題之迴圈鏈結表

資料結構原始碼筆記(c語言):多項式合併

資料結構原始碼筆記(c語言):二叉樹之葉子結點旋轉銷毀

資料結構原始碼筆記(c語言):哈夫曼樹

資料結構原始碼筆記(c語言):集合的位向量表示

資料結構原始碼筆記(c語言):鏈結佇列

資料結構原始碼筆記(c語言):鏈結棧

資料結構原始碼筆記(c語言):線性表的單鏈表示

資料結構原始碼筆記(c語言):線性表的順序表示

資料結構原始碼筆記(c語言):棧的基本操作

資料結構原始碼筆記(c語言):中綴表示式

資料結構原始碼筆記(c語言):希爾插入排序

資料結構原始碼筆記(c語言):索引檔案建立和查詢

資料結構原始碼筆記(c語言):氣泡排序

資料結構原始碼筆記(c語言):快速排序

資料結構原始碼筆記(c語言):可變長度字串的快速排序

資料結構原始碼筆記(c語言):基數排序

資料結構原始碼筆記(c語言):二路歸併排序

資料結構原始碼筆記(c語言):堆排序

資料結構原始碼筆記(c語言):二叉樹搜尋樹kruskal

資料結構原始碼筆記(c語言):二叉搜尋樹prim

資料結構原始碼筆記(c語言):最短路徑弗洛伊德演算法

資料結構原始碼筆記(c語言):深度、廣度優先生成樹

資料結構原始碼筆記(c語言):鄰接矩陣轉化鄰接表

資料結構原始碼筆記(c語言):統計字串**現的字元及其次數

資料結構原始碼筆記(c語言):順序查詢

資料結構原始碼筆記(c語言):分塊法查詢

資料結構原始碼筆記(c語言):二分查詢

資料結構原始碼筆記(c語言):二叉樹遍歷

資料結構原始碼筆記(c語言):二叉平衡樹的相關操作演算法

資料結構原始碼筆記(c語言):二叉排序樹的基本操作演算法

資料結構原始碼筆記(C語言) 堆排序

實現堆排序演算法 include include define maxe 20 typedef int keytype typedef char infotype 10 typedef struct rectype void dispheap rectype r,int i,int n 按遞增有序進...

資料結構原始碼筆記(C語言) 鏈結棧

鏈結棧 型別和介面函式宣告 include include typedef int datatype struct node 單鏈表結點 typedef struct node pnode 指向結點的指標型別 struct node struct linkstack 鏈結棧型別定義 typedef ...

資料結構原始碼筆記(C語言) 直接選擇排序

實現直接選擇排序演算法 include include define maxe 20 typedef int keytype typedef char infotype 10 typedef struct rectype void selectsort rectype r,int n 直接選擇排序演...