关键词不能为空

当前您在: 主页 > 高中公式大全 >

重要极限公式的推广构造任意合式公式的真值表

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2020-10-11 00:03
tags:公式int

庄子的思想主张-两个一百年的奋斗目标是什么

2020年10月11日发(作者:窦常)
构造任意合式公式的真值表

#include
#include
int main()
{
Thesis a[30];
char x='1';
int i=0,N;
cout<<请输入命题变元(不超过30个)(输入'0'结束
输入):
while(int(x)!=48)
{
cin>>x;
if(i>19)
{cout<<变元个数太多!
if(x!='0')
{
a[i].inname(x);
i++;
}
}
N=i;
int M;
M=N;
string A;
cout<<请输入命题公式( 否定:!,合取:&,析取:
| )
cin>>A;
cout< for(int j=0;j cout< cout<<真值
assignment(A,N,M,&a[0]);
system(
return 0;
}


#include

#ifndef THESIS_H
#define THESIS_H
#include
#include
#include
using namespace std;
class Thesis 命题类
{
int value;char name; value:命题的真值(01)
name:命题名
public:
Thesis(){value=2;name='A';};
friend Thesis operator !(Thesis &q)
{e(ue()); return q;}
重载逻辑运算符
friend Thesis operator &(Thesis &p,Thesis &q)
{e((ue()+ue())2);
p;}
friend Thesis operator |(Thesis &p,Thesis &q)
return
{if(ue()+ue()>0) e(1);
else e(0);
return p;}
friend Thesis operator >(Thesis &p,Thesis &q)
{if(ue()==1&&ue()==0)
e(0);
else e(1);
return p;}
friend Thesis operator <(Thesis &p,Thesis &q)
{if(ue()==ue()) e(1);
else e(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;} 获取命题名
};
void assignment(string A,int N,int M,Thesis a[]);
声明函数
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[])命
题赋值并计算真值
{
for(int j=0;j<2;j++)
{
a[N-1].invalue(j);
if(N>1)
{
assignment(A,N-1,M,&a[0]);
}
else
{
for(int i=0;i {
cout< }
cout< }
}
}
int bds(string A,int N,Thesis a[])
入的表达式并计算真值
识别输
{
Thesis answer,Temp;
char d[5]={'!','|','&','>','<'}; 定义运算符号集合
int L;
int i=0;
L=strlen(&A[0]); 表达式长度
while(i {
if(A[i]=='(')
{
int k=1;
for(int j=i+2;j {
if(k!=0)
{
if(A[j]=='(')
k++;
if(A[j]==')')
k--;
}
if(k==0)
{
int l=j-i-1;
char *p=new char[l+1];
string B;
for(int m=0;m p[m]=A[i+1+m];
p[l]='0';
B=p;
delete p;
e(bds(B,N,&a[0]));
if(i==0)
e(ue());
i=j+1;
break;
}
}
}
else
{
if(A[i]=='!') 否定的计算
{
e(run(A,i,L,N,&a[0]));
answer=!Temp;
i++;
continue;
}
else if(A[i]=='|')
{
e(run(A,i,L,N,&a[0]));
answer=answer|Temp;
i++;
continue;
}
else if(A[i]=='&')
{
e(run(A,i,L,N,&a[0]));
answer=answer&Temp;
i++;
continue;
}
else if(A[i]=='<')
{
e(run(A,i,L,N,&a[0]));
answer=answer i++;
continue;
}
else if(A[i]=='>')
{
e(run(A,i,L,N,&a[0]));
answer=answer>Temp;
i++;
continue;
}
else
{
for(int j=0;j {if(A[i]==char(a[j].getname()))
{
e(a[j].getvalue());
if(i==0)
e(ue());
i++;
break;
}
}
}
}
}
return ue();
}
int run(string A,int &i,int L,int N,Thesis a[])
{
Thesis Temp;
if(A[i+1]=='(')
{
int k=1;
for(int j=i+2;j {
if(k!=0)
{
if(A[j]=='(')
k++;
if(A[j]==')')
k--;
}
if(k==0)
{
int l=j-i-1;
char *p=new char[l+1];
string B;
for(int m=0;m p[m]=A[i+2+m];
p[l-1]='0';
B=p;
delete p;
e(bds(B,N,&a[0]));
i=i+j;
break;
}
}
}
else
{
int j=0;
while(j {
if(A[i+1]==char(a[j].getname()))
{
i++;
Temp=a[j];
break;
}
j++;
}
}
return ue();
}
#endif


乐不思蜀的是谁-酒泉职业技术学校


很甜很撩男生的短句-眼睛激光手术能做吗


地球表面约多少被水覆盖-四个选择是什么


星期日英文-26个字母的音标发音


1秒多少毫秒-掌门对1怎么样


静摩擦力与滑动摩擦力-勿


北京交通大学怎么样-形容失望和心凉的诗词


河南省高等专科学校-中专升大专



本文更新与2020-10-11 00:03,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/413230.html

构造任意合式公式的真值表的相关文章