Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- main()
- {
- float a, b, c, D, xim, x1, x2, x3, x4, m, s1, s2, t;
- cin >> a >> b >> c;
- D = b*b - 4*a*c;
- if (D<0)
- {
- xim = sqrt(abs(D));
- t = ((-1)*b)/(2*a);
- m = xim/(2*a);
- cout << "t1 = " << t << " + j" << m << endl;
- cout << "t2 = " << t << " - j" << m << endl;
- }
- else if (D>=0)
- {
- s1 = ((-1)*b)/(2*a);
- s2 = (sqrt(abs(D)))/(2*a);
- if (s1 + s2 < 0)
- {
- x1 = sqrt (abs(s1+s2));
- cout << "x1 = j" << x1 << endl;
- cout << "x2 = -j" << x1 << endl;
- }
- else
- {
- x1 = sqrt (s1+s2);
- x2 = (-1) * x1;
- cout << "x1 = " << x1 << endl;
- cout << "x2 = " << x2 << endl;
- }
- if (s1 - s2 < 0)
- {
- x3 = sqrt (abs(s1-s2));
- cout << "x3 = j" << x3 << endl;
- cout << "x4 = -j" << x3 << endl;
- }
- else
- {
- x3 = sqrt (s1-s2);
- x4 = (-1) * x3;
- cout << "x3 = " << x3 << endl;
- cout << "x4 = " << x4 << endl;
- }
- }
- system ("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment