fork download
  1. #include <iostream>
  2. using namespace std ;
  3. #include <math.h>
  4. main()
  5. {
  6. int a,b,c;
  7. float d;
  8. cin>>a>>b>>c;
  9. d=(b*b-4*a*c);
  10. if (a==0)
  11. cout<<"phuong trinh co 1 nghiem duy nhat "<<float(-c/b);
  12.  
  13. else
  14. {
  15. if (a!=0)
  16. if (d<0)
  17. cout<<"phuong trinh vo nghiem";
  18. else
  19. if (d=0)
  20. cout<<"phuong trinh co nghiem kep"<<float(-b/(2*a));
  21. else
  22. if (d>0)
  23. cout<<"phuong trinh co 2 nghiem phan biet"<<(float)((-b+sqrt(d))/(2*a));
  24. cout<<"phuong trinh co 2 nghiem phan biet"<<(float)((-b-sqrt(d))/(2*a));
  25.  
  26. }
  27. }
Success #stdin #stdout 0s 16064KB
stdin
2
3
5
stdout
phuong trinh vo nghiemphuong trinh co 2 nghiem phan biet-nan