Advertisement
Guest User

Untitled

a guest
Sep 9th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main (){
  7.  
  8. double a, b, c;
  9.  
  10. cin >> a >> b >> c;
  11.  
  12. double discriminant =  (b * b) - (4 * a * c);
  13.  
  14.  
  15. cout.precision(2);
  16.  
  17. if (discriminant < 0){
  18.     cout << "no roots" << endl;
  19. } else if (discriminant == 0){
  20.     cout << (-b / 2 * a);
  21. } else {
  22.     cout << (-b + sqrt(discriminant)) / (2 * a) << " " << (-b - sqrt(discriminant)) / (2 * a);
  23. }
  24.  
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement