fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. double a, b, c, d, r1, r2;
  6. cin >> a >> b >> c;
  7.  
  8. d = sqrt(b*b - 4*a*c);
  9. r1 = (-b + d) / (2*a);
  10. r2 = (-b - d) / (2*a);
  11.  
  12. cout << "Roots are " << r1 << " and " << r2;
  13. }
Success #stdin #stdout 0s 5320KB
stdin
1 -3 2
stdout
Roots are 2 and 1