Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. double a,b,c;
  8. double x=0;
  9. cin>>a>>b>>c;
  10.  
  11. double delta = (b*b)-(4*a*c);
  12.  
  13. if(a==0)
  14. {
  15. if(b==0)
  16. {
  17. if(c==0)
  18. {
  19. cout<<"NWR"<<endl;
  20. }
  21. else
  22. cout<<"BR"<<endl;
  23. }
  24. else
  25. {
  26. double x=-b/c;
  27. cout<<x;
  28. }
  29. }
  30. else
  31. if(delta>0)
  32. {
  33. double x1=(-b-(sqrt(delta)))/(2*a);
  34. double x2=(-b+(sqrt(delta)))/(2*a);
  35. cout.precision(2);
  36. cout<<fixed<<"x1= "<<x1<<endl;
  37. cout<<fixed<<"x2= "<<x2<<endl;
  38.  
  39. }
  40. else
  41. if(delta==0)
  42. {
  43. double xx=-b/2*a;
  44. cout<<xx;
  45. }
  46. else
  47. cout<<"BR";
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement