Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void RealRootsQadrEqua(double a, double b, double c)
- {
- double D = pow(b, 2) - 4 * a * c;
- double x1=0;
- double x2=0;
- if (D < 0)
- {
- cout << "No real roots";
- }
- else if (D = 0)
- {
- x1 = -b / (2.0 * a);
- cout << x1;
- }
- else
- {
- x1 = (-b + sqrt(D)) / 2 * a;
- x2 = (-b - sqrt(D)) / 2 * a;
- cout << x1 << x2;
- }
- }
- int main()
- {
- double a, b, c;
- cin >> a >> b >> c;
- RealRootsQadrEqua(a, b, c);
- //double x1;
- //double x2;
- //double D = pow(b, 2) - 4 * a * c;
- //x1 = (-b + sqrt(D)) / 2 * a;
- //x2 = (-b - sqrt(D)) / 2 * a;
- //cout << x1 << x2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement