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

35 lines
547 B
C++
Raw Normal View History

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