fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int a,b,c;
  7. cin>>a>>b>>c;
  8. int d =b*b-4*a*c;
  9. if(d<0){
  10. cout<<"No real root";
  11. return 0;
  12. }else if(d==0){
  13. cout<<"Two same roots x=";
  14. cout<<0-b/(2*a);
  15. }else{
  16. d=sqrt(d);
  17. cout<<"Two different roots x1=";
  18. cout<<((0-b)+d)/(2*a);
  19. cout<<" , x2=";
  20. cout<<((0-b)-d)/(2*a);
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5284KB
stdin
1 1 1
stdout
No real root