Advertisement
alaminrifat

URI -1036 with C++

Apr 19th, 2020
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. double a,b,c,r1,r2,d;
  7. cin>>a>>b>>c;
  8. d=(pow(b,2)-(4*a*c));
  9. r1=(-b+sqrt(d))/(2*a);
  10. r2=(-b-sqrt(d))/(2*a);
  11. cout.precision(5);
  12. if(a!=0 && d>0)
  13. {
  14.     cout<<fixed<<"R1 = "<<r1<<endl;
  15.     cout<<fixed<<"R2 = "<<r2<<endl;
  16. }
  17. else{
  18.     cout<<"Impossivel calcular\n";
  19. }
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement