Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- double a, b, c;
- cin >> a >> b >> c;
- double d = (b * b) - (4 * a * c);
- double y1 = (-b + sqrt(d)) / a;
- double y2 = (-b + sqrt(d)) / a;
- if (std::isnan(y1) && std::isnan(y2))
- {
- if (y1 > 0 && y2 > 0)
- {
- cout << "x1 = " << sqrt(y1);
- cout << "x2 = " << sqrt(y2);
- }
- else if (y1 > 0 && y2 < 0)
- {
- cout << "x1 = " << sqrt(y1);
- }
- else if (y2 > 0 && y1 < 0)
- {
- cout << "x1 = " << sqrt(y2);
- }
- else
- {
- cout << "Error";
- }
- }
- else
- {
- cout << "Wrong numbers!";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement