Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- double a, b, c, d, x1, x2;
- cin >> a >> b >> c;
- d = b*b - 4*a*c;
- if (a == 0)
- if (b == 0)
- if (c == 0) cout << -1;
- else cout << 0;
- else
- {
- cout << 1 << endl;
- cout << setprecision(6) << c*(-1)/b;
- }
- else
- if (d < 0)
- {
- cout << 0;
- }
- else
- if (d == 0)
- {
- cout << 1 << endl;
- x1 = (b*(-1) + sqrt(d))/(2*a);
- cout << setprecision(6) << x1;
- }
- else
- {
- cout << 2 << endl;
- x1 = (b*(-1) - sqrt(d))/(2*a);
- x2 = (b*(-1) + sqrt(d))/(2*a);
- cout << setprecision(6) << x1 << endl;
- cout << setprecision(6) << x2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement