-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.cpp
More file actions
33 lines (28 loc) · 719 Bytes
/
Script.cpp
File metadata and controls
33 lines (28 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string.h>
// func that prints eqs in the from of ax+by=c
void PrintEq(float a, float b, float c)
{
std::cout << a << "x + " << b << "y = " << c << std::endl;
}
// func that prints the solution of name=value
void PrintSol(std::string name, float value)
{
std::cout << name << " = " << value << std::endl;
}
// the actual numbers, the float is the intial number.
int main()
{
float a = 2.0f;
float b = 1.0f;
float c = 7.0f;
float d = 1.0f;
float e = -1.0f;
float f = 5.0f;
PrintEq(a, b, c);
PrintEq(d, e, f);
float x = (c * e - b * f) / (e * a - b * d);
float y = (a * f - d * b) / (e * a - b * d);
PrintSol("x", x);
PrintSol("y", y);
}