aboutsummaryrefslogtreecommitdiff
path: root/C_C++/QuadraticEquationGrapher.cpp
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-11-12 09:23:19 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-11-12 09:23:19 +0200
commitdbaf69f0e0ede46cbf5765cb6ca9500fcd7a3ea7 (patch)
tree42890f66de25479419a2be48af695f79be7c155d /C_C++/QuadraticEquationGrapher.cpp
parentda0cd9df96b09425416869e819af9633866374ab (diff)
downloadalgorithms-dbaf69f0e0ede46cbf5765cb6ca9500fcd7a3ea7.tar
algorithms-dbaf69f0e0ede46cbf5765cb6ca9500fcd7a3ea7.tar.gz
algorithms-dbaf69f0e0ede46cbf5765cb6ca9500fcd7a3ea7.zip
Divided C and C++ files into seperate folders
Diffstat (limited to 'C_C++/QuadraticEquationGrapher.cpp')
-rw-r--r--C_C++/QuadraticEquationGrapher.cpp63
1 files changed, 0 insertions, 63 deletions
diff --git a/C_C++/QuadraticEquationGrapher.cpp b/C_C++/QuadraticEquationGrapher.cpp
deleted file mode 100644
index 7dfbe64..0000000
--- a/C_C++/QuadraticEquationGrapher.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <iostream>
-#include <math.h>
-
-using namespace std;
-
-/* Program that graphs a quadratic equation on the standard output */
-
-/* Equation precision - how precise the quadratic equation result should be
- * - higher values are more precise, but they could not show up on the graph
- * - needs to be balanced with step
- * Step - size of each unit (character)
- */
-const int eqPrec = 1;
-const double step = 1;
-
-const char line = '*';
-const char verLine = '|';
-const char horLine = '-';
-const char empty = ' ';
-
-double quadr(double x, double a, double b, double c) {
- return double( round( ( (a*pow(x, 2)) + (b*x) + c) * eqPrec ) / eqPrec);
-}
-
-void printQadr(int startx, int endx, int starty, int endy, double a, double b, double c) {
- double currY, currX;
- for (int y = max(starty, endy); y >= min(starty, endy); y--) {
- for (int x = startx; x <= endx; x++) {
- currY = y * step;
- currX = x * step;
-
- if (quadr(currX, a, b, c) == currY
- || ((quadr(currX, a, b, c) < currY
- || (quadr(currX - step, a, b, c) == 0 || quadr(currX + step, a, b, c) == 0)) // Wide lines
- && (quadr(currX + step, a, b, c) > currY != quadr(currX - step, a, b, c) > currY)) // Long lines
- ) {
- cout << line;
- } else if (x == 0) {
- cout << verLine;
- } else if (y == 0) {
- cout << horLine;
- } else {
- cout << empty;
- }
- }
- cout << endl;
- }
-}
-
-void printQadr(int start, int end, double a, double b, double c) {
- printQadr(start, end, start, end, a, b, c);
-}
-
-int main()
-{
- double a = 0.2;
- double b = 2;
- double c = -10;
-
- printQadr(-25, 15, 20, -15, a, b, c);
-
- return 0;
-}