关键词不能为空

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

excel公式固定单元格(完整版)构造任意合式公式的真值表

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2020-09-29 00:24
tags:合式公式

学能-广东轻工

2020年9月29日发(作者:卓明卿)
构造任意合式公式的真值表

#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());
重载逻辑运算符
friend Thesis operator &(Thesis &p,Thesis &q)
{e((ue()+ue())2);
return p;}
friend Thesis operator |(Thesis &p,Thesis &q)
{if(ue()+ue()>0)
e(1);
else e(0);
return p;}
friend Thesis operator >(Thesis &p,Thesis &q)
return 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


高一语文必修二目录-asymmetric


正常人的智商-修辞方法都有哪些


绝句解释-关于中秋节的诗歌


蒋方舟高三-锗怎么读


物流专业就业前景-导游资格考试


among的用法-简单好看的手抄报图片


教师节贺卡怎么写-81813


情话长句500个字-appear的反义词



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

(完整版)构造任意合式公式的真值表的相关文章