


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、構(gòu)造任意合式公式的真值表#include stdio.h #includethesis.h int main()thesis a30; char x=1; int i=0,n;cout請(qǐng)輸入命題變?cè)?不超過 30 個(gè))(輸入0結(jié)束輸 入 ):x; if(i19)couterror:變?cè)獋€(gè)數(shù)太多!endl;break;if(x!=0)ai.inname(x); i+;n=i;int m;m=n;string a;cout請(qǐng)輸入命題公式( 否定:!,合?。?,析?。簗 )a;couta的真值表為:endl;for(int j=0;jm;j+) coutchar(aj.getvalue(); cou
2、t 真 值 endl; assignment(a,n,m,&a0);system(pause); return 0;#includethesis.h#ifndef thesis_h #define thesis_h #include#include #include using namespace std;class thesis/命題類int value;char name;/value:命題的真值( 0/1) name:命題名public:thesis()value=2;name=a; friend thesis operator !(thesis &q)q.invalue(1-q.get
3、value(); return q;/重載邏輯運(yùn)算符friend thesis operator &(thesis &p,thesis &q)p.invalue(p.getvalue()+q.getvalue()/2); return p; friend thesis operator |(thesis &p,thesis &q)if(p.getvalue()+q.getvalue()0) p.invalue(1); else p.invalue(0);return p;friend thesis operator (thesis &p,thesis &q)if(p.getvalue()=1&
4、q.getvalue()=0) p.invalue(0);else p.invalue(1);return p;friend thesis operator (thesis &p,thesis &q)if(p.getvalue()=q.getvalue()p.invalue(1); else p.invalue(0);return p;void invalue(int x)value=x;/ 輸 入 value void inname(char x)name=x;/輸入 name int getvalue()return value;/獲取真值int getname()return name;
5、/獲取命題名;void assignment(string a,int n,int m,thesis a);/聲明函數(shù)int bds(string a,int n,thesis a);int run(string a,int &i,int l,int n,thesis a);void assignment(string a,int n,int m,thesis a)/命題賦值并計(jì)算真值for(int j=0;j1)assignment(a,n-1,m,&a0);elsefor(int i=0;im;i+)coutai.getvalue();coutbds(a,m,&a0),;/定義運(yùn)算符號(hào)集合
6、int l;int i=0;l=strlen(&a0);/表達(dá)式長(zhǎng)度while(il)if(ai=()int k=1;for(int j=i+2;jl;j+)if(k!=0)if(aj=() k+; if(aj=)k-;if(k=0)int l=j-i-1;char *p=new charl+1; string b;for(int m=0;ml;m+) pm=ai+1+m;pl=0;b=p;elsedelete p; temp.invalue(bds(b,n,&a0); if(i=0)answer.invalue(temp.getvalue(); i=j+1;break;if(ai=!)/否定
7、的計(jì)算temp.invalue(run(a,i,l,n,&a0); answer=!temp;i+;continue;else if(ai=|)temp.invalue(run(a,i,l,n,&a0); answer=answer|temp;i+;continue;else if(ai=&)temp.invalue(run(a,i,l,n,&a0); answer=answer&temp;i+;continue;else if(ai=)temp.invalue(run(a,i,l,n,&a0); answer=answer)temp.invalue(run(a,i,l,n,&a0); ans
8、wer=answertemp;i+;continue;elsefor(int j=0;jn;j+)if(ai=char(aj.getname()temp.invalue(aj.getvalue(); if(i=0)answer.invalue(temp.getvalue(); i+;break;return answer.getvalue();int run(string a,int &i,int l,int n,thesis a)thesis temp;if(ai+1=()int k=1;for(int j=i+2;jl;j+)if(k!=0)if(aj=() k+; if(aj=)k-;i
9、f(k=0)int l=j-i-1;char *p=new charl+1; string b;for(int m=0;ml-1;m+) pm=ai+2+m;pl-1=0;b=p;delete p;temp.invalue(bds(b,n,&a0); i=i+j;break;elseint j=0; while(jl)if(ai+1=char(aj.getname()i+;temp=aj; break;j+;return temp.getvalue();#endif“”“”at the end, xiao bian gives you a passage. minand once said,
10、people who learn to learn are very happy people. in every wonderful life, learning is an eternal theme. as a professional clerical and teaching position, i understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning can achieve better self. only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO 11901-1:2025 EN Tools for pressing - Gas springs - Part 1: General specifications
- 【正版授權(quán)】 ISO 9466:2025 EN Railway applications - Coating of passenger rail vehicles
- 【正版授權(quán)】 ISO/IEC 15045-4-2:2024 EN Information technology - Home Electronic System (HES) gateway - Part 4-2: Structure - Simple gateway
- 2025年物流運(yùn)輸項(xiàng)目融資擔(dān)保合同匯編
- 2025年度綠色能源項(xiàng)目融資居間合作協(xié)議范本
- 幼兒園健康教育教學(xué)計(jì)劃
- 林業(yè)行業(yè)會(huì)計(jì)個(gè)人工作計(jì)劃
- 財(cái)務(wù)信息化建設(shè)方案計(jì)劃
- 學(xué)習(xí)成果與展示活動(dòng)計(jì)劃
- 前臺(tái)工作中的情緒管理技巧計(jì)劃
- 安全生產(chǎn)事故調(diào)查與案例分析(第3版)課件 呂淑然 第1-4章 緒論-應(yīng)急預(yù)案編制與應(yīng)急管理
- Starter Unit 1 Hello!說課稿2024-2025學(xué)年人教版英語七年級(jí)上冊(cè)
- Unit 7 第3課時(shí) Section A (Grammar Focus -4c)(導(dǎo)學(xué)案)-【上好課】2022-2023學(xué)年八年級(jí)英語下冊(cè)同步備課系列(人教新目標(biāo)Go For It!)
- 2024-2025學(xué)年廣東省深圳市寶安區(qū)高一(上)期末數(shù)學(xué)試卷(含答案)
- 《基于新課程標(biāo)準(zhǔn)的初中數(shù)學(xué)課堂教學(xué)評(píng)價(jià)研究》
- 省級(jí)產(chǎn)業(yè)園區(qū)基礎(chǔ)設(shè)施項(xiàng)目可行性研究報(bào)告
- 2025年中國(guó)東方航空招聘筆試參考題庫(kù)含答案解析
- 《微生物燃料電池MF》課件
- 同濟(jì)大學(xué)《線性代數(shù)》-課件
- 醫(yī)院廉潔自律承諾書
- 申請(qǐng)兩癌補(bǔ)助申請(qǐng)書
評(píng)論
0/150
提交評(píng)論