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