當前位置:編程學習大全網 - 編程語言 - 用C語言編程:輸入命題公式的合式公式,求出公式的真值表,並輸出該公式的主合取範式和主析取範式

用C語言編程:輸入命題公式的合式公式,求出公式的真值表,並輸出該公式的主合取範式和主析取範式

A-Z + is OR * is AND _ is → # is⊕(圓圈裏加個bai+) @ is ⊙

$ is ↑ 命題的"與非" 運算du( "與非門zhi" )

% is ↓ 命題的"或非"運算( "或非門" )

Input the source formula:

A*!S+R

NORMALc: (!A*!B*!R)+(A*!B*!R)+(!A*B*!R)+(A*B*!R)+(!A*!B*R)+(!A*B*R)+(A*B*R)

NORMALd (!A+B+!R)

Error!

Input the source formula:

A#B

Here!

4countTerms

NORMALc: (A*!B)+(!A*B)

NORMALd (A+B)*(!A+!B)

Error!

Input the source formula:

stack<char> stk;

bool isVar(char ch)const;

void addMin(int minterm);

void addMax(int maxterm);

bool compute(int minterm);

void getInversePoland();

int countTerms(int n);

void assign(int minterm);

stack<bool> boolStk;

public:

formulaBase();

formulaBase(const formulaBase& rhs);

~formulaBase();

void getSource();

cout<<"Invalid input !"

"Operate again:"<<endl;

cin>>sourceFormula;*/

}

void formulaBase::getInversePoland()

{

char temp,temp1;

for(int i=0;sourceFormula[i]!='\0';i++)

stk.pop();

}

else break;

}

stk.push(temp);

break;

case '*':

while (!stk.empty())

//從鍵盤上任bai意輸入壹個主析取範式du,輸出與之等值的zhi主合取範式。┐∧∨

# include <iostream>

# include <cmath>

# include <windows.h>

using namespace std ;

擴展資料:

(1)命題變項是命題公式。

(2)如果A是命題公式,則?A是命題公式。

(3)如果A和B是命題公式,那麽(A∧B)、(A∨B)、(A→B)和(A?B)都是命題公式。

(4)當且僅當有限次地應用(1),(2),(3)所得到的包含命題變項,聯結詞和圓括號的符號串是命題公式。

命題公式的定義是壹個遞歸定義形式。命題公式本身不是命題,沒有真值,只有對其命題變項進行賦值後,它才有真值。

5個聯結詞運算兒有不同的優先級。當它們同時出現在壹個命題公式裏時,聯結間運算的優先次序為、∧、∨、→、,如果有括號,則括號內的運算優先進行。

百度百科-命題公式

  • 上一篇:ug2020配置要求
  • 下一篇:電腦開機刷新之後圖標顯示不出來。。。。。。急急急急
  • copyright 2024編程學習大全網