Advertisement
2607

Hello, world!

Jan 28th, 2020
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main(){
  8.   int A, B, C, D;    
  9.   cin>>A>>B>>C;
  10.   D=B*B-4*A*C;
  11.   if(D<0){
  12.       cout<<"No roots";
  13.   }
  14.   else{
  15.       if(D==0){
  16.           cout<<-B/(2*A);
  17.       }
  18.       else{
  19.           cout<<(-B-sqrt(D))/(2*A)<<"; "<<(-B+sqrt(D))/(2*A);
  20.       }
  21.   }
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement