思路参考:https://blog.csdn.net/wjh2622075127/article/details/79843339 感谢作者。
试着写了一下头文件,并修改优化了。
头文件:
#ifndef TRUTH_TABLE_H
#define TRUTH_TABLE_H
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;
class TruthTable
{
friend void read(istream& is, TruthTable& formula); //读取输入
friend void print(TruthTable& formula); //计算并输出
public:
void GetVariable(string str, string& var, int& count); //获取命题变元
void fei(string& str); //非
void hequ(string& str); //合取
void xiqu(string& str); //析取
void tiaojian(string& str); //条件
void shuangtiaojian(string& str); //双条件
void ToValue(string& str, int val[]); //赋真值给 变元
void DelKuohao(string& str);