Guest User

Untitled

a guest
Jan 4th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. void gr2eq()
  2. {
  3.  
  4. int a, b, c;
  5. scanf("%d%d%d", &a, &b, &c);
  6. int delta = b * b - 4 * a * c;
  7. float rootDelta;
  8. float realPart;
  9. if (delta == 0)
  10. printf("x1 = x2 = %.2f\n", -b / 2.0f / a);
  11. else if (delta > 0)
  12. {
  13. rootDelta = sqrt(delta);
  14. printf("x1 = %.2f, x2 = %.2f\n", (-b + rootDelta) / 2 / a, (-b - rootDelta) / 2 / a);
  15. }
  16. else
  17. {
  18. // camel case
  19. realPart = -b / (2.0f * a);
  20. rootDelta = sqrt(-delta);
  21. rootDelta /= 2 * a;
  22. rootDelta = rootDelta / 2 / a;
  23.  
  24. printf("x1 = %.2f + %.2fi, x2 = %.2f + %.2fi\n",
  25. realPart, rootDelta, realPart, -rootDelta);
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment