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;
- int d;
- d = b * b - (4 * a* c);
- double x1, x2;
- x1 = (-b + sqrt(d)) / (2 * a);
- x2 = (-b - sqrt(d)) / (2 * a);
- if (d < 0) {
- cout << "no roots" << endl;
- }
- else if (x1 == x2) {
- cout << x1;
- }
- else {
- if (x1 != 0) {
- cout << x1 << " ";
- }
- if (x2 != 0) {
- cout << x2;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement