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