




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、#include#includeusingnamespacestd;/charAns20;intGet_CLong(char*A_Char);/計(jì)算字符串的長(zhǎng)度boolB_Equal(char*C_temp1,char*C_temp2);/判斷兩個(gè)字符串是否一樣boolB_Belong(charx,char*X);/判斷x是否屬于X/char*Get_Closure(Function_Set*F,char*X);/求X在F上的閉包集structFunctioncharset_left20;intleft;charset_right20;intright;Function*next;Functi
2、on()next=NULL;classFunction_Setprivate:Function*head;public:Function_Set();/構(gòu)造函數(shù)voidAdd_Function(char*,int,char*,int);/建立新的關(guān)系結(jié)點(diǎn)voidClear_Function();/清空表boolCheak_Function(Function*);/檢查該關(guān)系是否已經(jīng)存在Function*Delete_Function(Function*);/刪除當(dāng)前節(jié)點(diǎn)Function*Get_Head();/返回頭結(jié)點(diǎn)voidGet_Collection(char*);/返回這個(gè)關(guān)系中的所有
3、元素voidOutput();/輸出;Function_Set:Function_Set()/構(gòu)造函數(shù)head=NULL;/head-next=NULL;Function*Function_Set:Delete_Function(Function*F_del)/刪除當(dāng)前節(jié)點(diǎn)Function*F_temp1=newFunction;F_temp1=head;if(head=NULL)elseif(head-next=NULL)(returnhead-next;)else(Function*F_temp1=newFunction;F_temp1=head;Function*F_temp2=newF
4、unction;F_temp2=head-next;while(F_temp2!=NULL)(if(B_Equal(F_del-set_left,head-set_left)&B_Equal(F_del-set_right,head-set_right)(head=head-next;returnhead;)elseif(B_Equal(F_del-set_left,F_temp2-set_left)&B_Equal(F_del-set_right,F_temp2-set_right)(F_temp1-next=F_temp2-next;returnF_temp1-next;)else(F_t
5、emp1=F_temp1-next;F_temp2=F_temp2-next;)returnNULL;)voidFunction_Set:Clear_Function()/清空表head=NULL;voidFunction_Set二Add_Function(char*t_sleft,intt_left,char*t_sright,intt_right)/增加一個(gè)關(guān)系結(jié)點(diǎn)Function*temp1=newFunction();for(inti=0;iset_lefti=t_slefti;temp1-left=t_left;for(inti=0;iset_righti=t_srighti;tem
6、p1-right=t_right;if(head=NULL)head=temp1;head-next=NULL;elseFunction*temp2=newFunction;temp2=head;while(temp2-next!=NULL)temp2=temp2-next;temp1-next=temp2-next;temp2-next=temp1;boolFunction_Set:Cheak_Function(Function*F_out)/檢查該關(guān)系是否已經(jīng)存在Function*F_temp1=newFunction;F_temp1=head;while(F_temp1!=NULL)if
7、(B_Equal(F_temp1-set_left,F_out-set_left)&B_Equal(F_temp1-set_right,F_out-set_right)returntrue;F_temp1=F_temp1-next;returnfalse;)Function*Function_Set:Get_Head()(returnhead;)voidFunction_Set:Get_Collection(char*C_temp1)/返回這個(gè)關(guān)系中的所有元素Function*F_temp1=newFunction;F_temp1=head;intI_temp2=0;while(F_temp1
8、!=NULL)for(inti=0;ileft;i+)輸入左側(cè)的元素if(!B_Belong(F_temp1-set_lefti,C_temp1)C_temp1I_temp2=F_temp1-set_lefti;I_temp2+;)for(inti=0;iright;i+)輸入右側(cè)的元素if(!B_Belong(F_temp1-set_righti,C_temp1)C_temp1I_temp2=F_temp1-set_righti;I_temp2+;)F_temp1=F_temp1-next;)cout關(guān)系中的所有元素為endl;for(inti=0;iGet_CLong(C_temp1);i
9、+)coutC_temp1i;)coutendl;)voidFunction_Set二Output()/輸出Function*temp2=newFunction;temp2=head;if(temp2=NULL)else(Function*temp1=newFunction;temp1=head;while(temp1!=NULL)(for(inti=0;ileft;i+)(coutset_lefti;)cout;for(inti=0;iright;i+)(coutset_righti;)coutnext;)structDevide/構(gòu)建一個(gè)分解的子關(guān)系chardev20;inttable;D
10、evide*next;);classDevide_Setprivate:Devide*head;intDS_table;public:Devide_Set();構(gòu)造函數(shù)Devide*Get_Head();/返回頭結(jié)點(diǎn)intGet_Long();/返回鏈表長(zhǎng)度voidAdd_Devide(char*);增加子關(guān)系voidOutput();輸出);Devide_Set:Devide_Set()/構(gòu)造函數(shù)head=NULL;DS_table=0;)Devide*Devide_Set二Get_Head()/返回頭結(jié)點(diǎn)returnhead;)intDevide_Set二Get_Long()/返回鏈表長(zhǎng)度
11、returnDS_table;)voidDevide_Set:Add_Devide(char*C_temp1)/增加子關(guān)系Devide*D_temp1=newDevide;intI_temp1;I_temp1=Get_CLong(C_temp1);for(inti=0;idevi=C_temp1i;)D_temp1-table=DS_table;DS_table+;/D_temp1-next=NULL;if(head=NULL)head=D_temp1;head-next=NULL;)elseDevide*D_temp2=newDevide;D_temp2=head;while(D_temp2
12、-next!=NULL)D_temp2=D_temp2-next;)D_temp1-next=D_temp2-next;D_temp2-next=D_temp1;)voidDevide_Set:Output()/輸出Devide*D_temp1=newDevide;D_temp1=head;while(D_temp1!=NULL)(intI_temp1;I_temp1=Get_CLong(D_temp1-dev);for(inti=0;iI_temp1;i+)(coutdevi;/couttable;coutnext;boolB_Contain(char*f_left,char*X)/判斷f_
13、left是否包含于Xinttemp1,temp2,temp3;temp1=Get_CLong(X);temp2=Get_CLong(f_left);temp3=0;for(inti=0;itemp1;i+)for(intk=0;ktemp2;k+)if(f_leftk=Xi)temp3+;if(temp3=temp2)returntrue;elsereturnfalse;boolB_Belong(charx,char*X)判斷x是否屬于Xinttemp1;temp1=Get_CLong(X);for(inti=0;itemp1;i+)(if(x=Xi)(returntrue;returnfal
14、se;boolB_Equal(char*C_temp1,char*C_temp2)/判斷兩個(gè)字符串是否相等intI_temp1;I_temp1=Get_CLong(C_temp1);if(I_temp1!=Get_CLong(C_temp2)returnfalse;elsefor(inti=0;iI_temp1;i+)if(*(C_temp1+i)!=*(C_temp2+i)returnfalse;returntrue;intGet_CLong(char*A_Char)/計(jì)算字符串的長(zhǎng)度inti=0;while(1)if(A_Chari64)i+;elsebreak;)returni;)voi
15、dSet_Null(char*C_temp1)/置空f(shuō)or(intii=0;ii20;ii+)C_temp1ii=;)voidOutput(char*C_temp1)/輸出for(inti=0;iGet_CLong(C_temp1);i+)coutC_temp1i;)voidGet_Part(char*C_Previa,char*C_Rest,charC_Certain)去除C_Previa中的C_CertainintI_temp1,I_temp2=0;I_temp1=Get_CLong(C_Previa);for(inti=0;iI_temp1;i+)if(C_Previai!=C_Cert
16、ain)C_RestI_temp2=C_Previai;I_temp2+;)voidGet_Closure(Function_Set*F,char*X,char*Ans)/計(jì)算閉包集inttemp1;charbackup20;Set_Null(backup);temp1=Get_CLong(X);for(inti=0;itemp1;i+)Ansi=Xi;)Function*f_temp2=newFunction;boolA=true;while(A)(temp1=Get_CLong(Ans);for(inti=0;iGet_Head();while(f_temp2!=NULL)/一輪選擇if(
17、B_Contain(f_temp2-set_left,Ans)/當(dāng)F的左集合包含于Ans時(shí)inttemp3;inttemp4=Get_CLong(Ans);temp3=f_temp2-right;for(inti=0;iset_righti,Ans)/當(dāng)Ans中不包含新的元素時(shí)Anstemp4=f_temp2-set_righti;temp4+;f_temp2=f_temp2-next;if(B_Contain(Ans,backup)A=false;/returnAns;voidDeal_Right(Function_Set*F,Function_Set*Ans)/將F右側(cè)的屬性集原子化Fun
18、ction*temp1=newFunction;inttemp2;temp1=F-Get_Head();while(temp1!=NULL)temp2=Get_CLong(temp1-set_right);for(inti=0;iCheak_Function(temp1)(Ans-Add_Function(temp1-set_left,Get_CLong(temp1-set_left),temp1-set_right+i,1);temp1=temp1-next;voidDeal_Redundancy_F(Function_Set*Ans)/去除冗余的函數(shù)依賴Function_Set*FS_te
19、mp1=newFunction_Set;Function*F_temp1=newFunction;Function*F_temp2=newFunction;F_temp1=Ans-Get_Head();指向當(dāng)前節(jié)點(diǎn)F_temp2=FS_temp1-Get_Head();指向G的頭結(jié)點(diǎn)while(F_temp1!=NULL)/對(duì)Ans里面所有的function遍歷charC_temp120;/當(dāng)前節(jié)點(diǎn)的左集Set_Null(C_temp1);charC_temp320;當(dāng)前節(jié)點(diǎn)的右集Set_Null(C_temp3);charC_temp220;/當(dāng)前節(jié)點(diǎn)在G上的閉包Set_Null(C_tem
20、p2);for(inti=0;ileft;i+)/存左集C_temp1i=F_temp1-set_lefti;for(inti=0;iright;i+)/存右集C_temp3i=F_temp1-set_righti;Function*F_temp4=Ans-Get_Head();/用于轉(zhuǎn)移F-G時(shí)while(F_temp4!=NULL)/構(gòu)建函數(shù)依賴集Gif(!B_Equal(F_temp4-set_left,C_temp1)|!B_Equal(C_temp3,F_temp4-set_right)FS_temp1-Add_Function(F_temp4-set_left,F_temp4-le
21、ft,F_temp4-set_right,1);F_temp4=F_temp4-next;)FS_temp1-Output();/coutendl;coutendl;Set_Null(C_temp2);Get_Closure(FS_temp1,C_temp1,C_temp2);/123/intI_temp2;I_temp2=Get_CLong(C_temp2);cout輸出左集在G的閉包;for(inti=0;iI_temp2;i+)輸出左集的閉包c(diǎn)outC_temp2i;)coutDelete_Function(F_temp1);/刪除當(dāng)前關(guān)系節(jié)點(diǎn)并且返回下一節(jié)點(diǎn)的地址)elseF_temp
22、1=F_temp1-next;)FS_temp1-Clear_Function();F_temp2=FS_temp1-Get_Head();)voidDeal_Redundancy_P(Function_Set*Ans)/去除元素冗余Function*F_temp1=newFunction;/初始狀態(tài)指向G的頭結(jié)點(diǎn)Function*F_temp2=newFunction;/指向當(dāng)前節(jié)點(diǎn)F_temp2=Ans-Get_Head();while(F_temp2!=NULL)charC_temp120;/存放閉包集Set_Null(C_temp1);charC_temp220;/存放G中的新的屬性集Set_Null(C_temp2);intI_temp1;if(Get_CLong(F_temp2-set_left)n
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 教材解析水利水電工程試題及答案
- 五年級(jí)心理健康成長(zhǎng)教育
- 物理學(xué)原理在工程中的應(yīng)用知識(shí)集萃
- 高爾夫運(yùn)動(dòng)基礎(chǔ)技能培訓(xùn)指南
- 教育科技產(chǎn)品研發(fā)合同
- 探索市政工程考試領(lǐng)域的試題及答案
- 企業(yè)臨時(shí)用工勞動(dòng)合同
- 經(jīng)濟(jì)師中級(jí)考試重要試題及答案提醒
- 物理實(shí)驗(yàn)答辯報(bào)告設(shè)計(jì)規(guī)范
- 學(xué)習(xí)“鑄牢中華民族共同體意識(shí)”應(yīng)知應(yīng)會(huì)知識(shí)競(jìng)賽測(cè)試題庫(kù)
- 私人建房委托協(xié)議書
- 基于大數(shù)據(jù)的新興市場(chǎng)機(jī)器人應(yīng)用模式研究-洞察闡釋
- 《艾薩克·牛頓》課件
- 抱負(fù)與使命主題作文導(dǎo)寫-2024-2025學(xué)年高一語(yǔ)文單元寫作深度指導(dǎo)(統(tǒng)編版必修下冊(cè))
- 福建省莆田市2025屆高中畢業(yè)班高三年級(jí)第四次教學(xué)質(zhì)量檢測(cè)試卷物理及答案(莆田四檢)
- 貨物裝卸倉(cāng)儲(chǔ)合同協(xié)議
- 2024年四川省寧南縣事業(yè)單位公開招聘醫(yī)療衛(wèi)生崗筆試題帶答案
- 初中數(shù)學(xué)融入課程思政的路徑探索
- 銀行資產(chǎn)負(fù)債管理試題及答案
- 壓力容器安全教育培訓(xùn)
- 托管機(jī)構(gòu)管理制度
評(píng)論
0/150
提交評(píng)論