




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include#include#include#define null 0typedef struct char var; char *s;mgu;void strreplace(char *string,char *str1,char *str2) char *p; while(p=strstr(string,str1) int i=strlen(string); int j=strlen(str2); *(string+i+j-1)=0; for(int k=i-1;(string+k)!=p;k-) *(string+k+j-1)=*(string+k); for(i=0;istrlen(str2);i+) *(p+)=*(str2+i); void sort(mgu *u,int count) int j=count; int k=j; if(count=1)return; for(int i=1;is) continue; if(u+i)-var=(u+j)-var) delete (u+j)-s; (u+j)-s=null; k-; j=i; if(u+i)-s)&(u+i)-var=*(u+i)-s) delete (u+i)-s; (u+i)-s=null; k-; j=count; if(k=j)return; count=k; for(int i=1;i0;i+) if(u+i)-s) continue; while(!(u+j)-s) j-; (u+i)-var= (u+j)-var; (u+i)-s= (u+j)-s; (u+j)-s=null; k-; coutgjvjkhllknkln;class unifier char *string; mgu unit50; int count;public:int num;unifier();void input();int differ(int n);int change(int i,int j,int n);void print();unifier()delete string;unifier:unifier()count=0;unit0.s=null;void unifier:input() cout endlnum; string=new charnum*50; cout请注意:公式的输入不能出错!endl; for(int j=1;j=num;j+) cout 请输入第 j 个原子谓词公式(字符个数不超过50个) (string+(j-1)*50); int unifier:change(int i,int j,int n)char temp210;temp00=stringi+;temp10=stringj+; if(stringi!=() temp01=0; else int k=1,flag=1; temp0k+=stringi+; while(flag!=0)&k10) if(stringi=() flag+; else if(stringi=) flag-; temp0k+=stringi+; temp0k=0; temp11=0; if(strlen(temp1)=1) if(strstr(temp0,temp1) return 2; strreplace(string+n*50,temp1,temp0); strreplace(string+(n+1)*50,temp1,temp0); count+; int m=count; unitm.var=temp10; char *p=new charstrlen(temp0)+1; unitm.s=p; strcpy(p,temp0); return 1; int unifier:differ(int n) int i=n*50,j=(n+1)*50; while(stringi!=0)&(stringj!=0)&(stringi=stringj) i+;j+; if(stringi=0|stringj=0) return 1; int k; if(stringi+1=() k=change(i,j,n); else if(stringj+1=() k=change(j,i,n); else if(stringj=x|stringj=y|stringj=z|stringj=u| stringj=v|stringj=w) k=change(i,j,n); else k=change(j,i,n); if(k=2) return k; j=count; char c2,*p; for(i=1;ij;i+) c0=unitj.var; c1=0; if(!strstr(uniti.s,c) continue; p=new charstrlen(unitj.s)+strlen(uniti.s)+1; strcpy(p,uniti.s); strreplace(p,c,unitj.s); delete uniti.s; uniti.s=p; sort(unit,count); return 0;void unifier:print() cout The MGU is ; for(int i=1;icount+1;i+) cout (uniti).s/uniti.var; if(icount) cout,; int once() unifier form; form.input(); if(form.num2) coutThe MGU is empty!endl; return form.num; int k=form.differ(0); if(k=1&form.num=2) coutThe MGU is empty!endl; return form.num; if(k=2) coutThe MGU is not exist!endl; return form.num; else if(k=0&form.num=2) while(k!=1) k=form.differ(0); if(k=2) coutThe MGU is not exist!endl; return form.num; form.print(); return form.num; for(k=0;kform.num-1;k
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 湖北省华师一附中2026届化学高三第一学期期末综合测试试题含解析
- 心肺复苏技术和除颤技术
- 2024学年广州市七年级语文上学期期中考试卷附答案解析
- 脑卒中科普讲解
- 牛蹄解剖生理讲解
- 桥梁施工安全技术交底
- 汽车试制会议汇报
- 石膏模型灌注技术
- 细胞生态关系图解
- 虚拟化技术培训
- 2025年传动部件行业当前发展趋势与投资机遇洞察报告
- 人大代表基础知识培训课件
- 2025年高压电工证考试题库及答案
- 2025-2026学年高一上学期开学第一课主题班会课件
- 光储充一体化项目可行性研究报告
- 2025年供热公司培训试题及答案
- 冠心病的防治指南
- 临建工程施工合同范本(2025版)
- G2电站锅炉司炉证考试题库及答案
- 架桥机架梁施工技术交底
- 屠宰加工人员职业技能模拟试卷含答案
评论
0/150
提交评论