This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2024_Stanislav_Mykhailenko/Lesson_1/Task_5/main.cpp
Stanislav Mykhailenko 0ae4eb5552
Fix Lesson 1
2024-06-11 10:48:26 +03:00

34 lines
547 B
C++

#include <cmath>
#include <complex>
#include <iostream>
using namespace std;
int main()
{
float a = 0;
float b = 0;
float c = 0;
float D = 0;
cout << "Enter a: ";
cin >> a;
cout << "Enter b: ";
cin >> b;
cout << "Enter c: ";
cin >> c;
D = pow(b, 2) - 4 * a * c;
complex<float> root = sqrt(complex<float>(D));
complex<float> x1 = (-b + root) / (2 * a);
complex<float> x2 = (-b - root) / (2 * a);
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
return 0;
}