using namespace std;
#define maxsize 20
#define true 1
#define false 0
typedef bool status; /* status是函式的型別,其值是函式結果狀態***/
typedef char elemtype; /* elemtype型別根據實際情況而定,這裡假設為int */
typedef struct
sqlist;
/*初始化順序表*/
status initlist(sqlist *&list)
/*建立順序表*/
status createlist(sqlist *&list, elemtype e, int len)
/*銷毀順序表*/
status destorylist(sqlist *&list)
/*判斷順序表是否為空*/
status listempty(sqlist *list)
/*返回順序表長度*/
int listlength(sqlist *list)
/*輸出鍊錶*/
void displaylist(sqlist *list)
/*獲取對應position位置上的值,放到e上*/
status getelem(sqlist *list, int position , elemtype &e)
/*尋找鍊錶中值為e的位置, 0表示沒有找到*/
int locateelem(sqlist *list, elemtype e)
/*插入e到position中*/
status listinsert(sqlist *&list, int position, elemtype e)
/*刪除position位置上的值,並把刪除的值通過e返回*/
status listdelete(sqlist *&list, int position, elemtype &e)
/*去兩個集合的合集, la和lb位要去合集的物件, lc為結果*/
void unionlist(sqlist *la, sqlist *lb, sqlist *&lc)
for(i = 1; i <= lenb; i++)
}void commonlist(sqlist *la, sqlist *lb, sqlist *&lc)
}void differencesetlist(sqlist *la, sqlist *lb, sqlist *&lc)
}int main()
; elemtype list_b[5] = ;
createlist(lista, list_a, 5);
cout << "線性表a的元素是:";
displaylist(lista);
createlist(listb, list_b, 6);
cout << "線性表b的元素是:";
displaylist(listb);
initlist(listc);
initlist(listd);
initlist(liste);
initlist(listf);
cout << "a ∪ b: ";
unionlist(lista, listb, listc);
displaylist(listc);
cout << "a ∩ b: ";
commonlist(lista, listb, listd);
displaylist(listd);
cout << "a - b: ";
differencesetlist(lista, listb, liste);
displaylist(liste);
cout << "b - a: ";
differencesetlist(listb, lista, listf);
displaylist(listf);
return 0;
}
交集並集差集
1 內連線 select from student a inner join sc b on a.sno b.sno 左連線 select from student a left join sc b on a.sno b.sno 差集 select sno from student except s...
shell bash 交集 並集 差集
方法一 直接用檔名 取兩個文字檔案的並集 交集 差集 並 sort m sort file1 uniq sort file2 uniq uniq 交 sort m sort file1 uniq sort file2 uniq uniq d 差 file1 file2 sort m sort fil...
PHP 交集 並集 差集
array flip array splice 並集 array merge 過濾 array filter 去重 array unique 差集 array diff array diff 函式返回兩個陣列的差集陣列。該陣列包括了所有在被比較的陣列中,但是不在任何其他引數陣列中的鍵值。a1 arr...