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