Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 16 / LogicExpressions
diff options
context:
space:
mode:
Commit9603d0847a01c555c2c9286294b3ccdea3e38be8 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2021-06-12 18:30:23 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2021-06-12 18:30:23 +0300
Filesd9ddae75f6bc77d353d74200ec897f3f3d7493a4 /Sem. 16/LogicExpressions
Object-oriented_programming_FMI-9603d0847a01c555c2c9286294b3ccdea3e38be8.tar
Object-oriented_programming_FMI-9603d0847a01c555c2c9286294b3ccdea3e38be8.tar.gz
Object-oriented_programming_FMI-9603d0847a01c555c2c9286294b3ccdea3e38be8.zip
Parentd489848bab395aea447bf6fe462f7c4f603dee1a (diff)
sem 16
2 files changed, 18 insertions, 3 deletions
-rw-r--r--Sem. 16/LogicExpressions/LogicExpressions/LogicExpr.h (renamed from Sem. 16/LogicExpressions/LogicExpr.h)6
-rw-r--r--Sem. 16/LogicExpressions/Source.cpp15
diff --git a/Sem. 16/LogicExpressions/LogicExpr.h b/Sem. 16/LogicExpressions/LogicExpressions/LogicExpr.h
index ebb84b4..9188541 100644
--- a/Sem. 16/LogicExpressions/LogicExpr.h
+++ b/Sem. 16/LogicExpressions/LogicExpressions/LogicExpr.h
@@ -123,7 +123,7 @@ namespace LogicExpressions
return std::move(current);
}
- bool CheckValues(LogicExpr* expr, const std::vector<char>& vars, bool value)
+ bool CheckValues(const LogicExpr* expr, const std::vector<char>& vars, bool value)
{
size_t checksCounts = 1 << vars.size();
@@ -137,12 +137,12 @@ namespace LogicExpressions
return true;
}
- bool isTautology(LogicExpr* expr, const std::vector<char>& vars)
+ bool isTautology(const LogicExpr* expr, const std::vector<char>& vars)
{
return CheckValues(expr, vars, true);
}
- bool isContradiction(LogicExpr* expr, const std::vector<char>& vars)
+ bool isContradiction(const LogicExpr* expr, const std::vector<char>& vars)
{
return CheckValues(expr, vars, false);
}
diff --git a/Sem. 16/LogicExpressions/Source.cpp b/Sem. 16/LogicExpressions/Source.cpp
new file mode 100644
index 0000000..2b810b8
--- /dev/null
+++ b/Sem. 16/LogicExpressions/Source.cpp
@@ -0,0 +1,15 @@
+#include "LogicExpressions/LogicExpr.h"
+
+using namespace LogicExpressions;
+
+
+int main()
+{
+ LogicExpr* expr = new Operation(new Var('p'), '|', new Negation(new Var('p'))); // p & !p
+ expr->print();
+ cout << " " << isTautology(expr, { 'p' }) << endl;
+
+ LogicExpr* expr2 = new Operation(new Var('q'),'^',new Operation(new Var('p'), '^', new Negation(new Var('p')))); // q ^ (p ^ !p)
+ expr2->print();
+ cout << " " << isContradiction(expr2, { 'p', 'q' });
+} \ No newline at end of file