Advertisement
2607

Untitled

Feb 20th, 2020
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "math.h"
  3.  
  4. int main()
  5. {
  6. int a, b, c, D;
  7. scanf("%d%d%d", &a, &b, &c);
  8. if(a==0)
  9. {
  10. if(b==0)
  11. {
  12. if (c==0)
  13. printf("x - all");
  14. else
  15. printf("no solution");
  16. }
  17. else
  18. {
  19. if(c==0)
  20. printf("x=0");
  21. else
  22. printf("%f", -(float)c/b);
  23. }
  24. }
  25. else
  26. {
  27. if(b==0)
  28. {
  29. if(c==0)
  30. printf("x=0");
  31. else
  32. {
  33. if(-(double)c/a>0)
  34. printf("%f", sqrt(-(double)c/a));
  35. else
  36. printf("no solution66");
  37. }
  38.  
  39. }
  40. else
  41. {
  42. D=b*b-4*a*c;
  43. if(D<0)
  44. printf("no solution");
  45. else
  46. {
  47. if(D=0)
  48. printf("%f", -(float)b/2/a);
  49. else
  50. printf("x1=%f, x2=%f", (float)(-b-sqrt(D))/2/a, (float)(-b+sqrt(D)/2/a));
  51. }
  52. }
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement