Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. int a, b, c, x, x1, x2, re, d, im;
  8. scanf("%d %d %d",&a, &b, &c);
  9. if (a == 0 && b == 0) {
  10. printf("Izrodeno uravnenie");
  11. } else if (a == 0) {
  12. x = -c / b;
  13. printf("Lineino uravnenie, x = %d", x);
  14. } else if (c == 0) {
  15. x1 = -b / a;
  16. x2 = 0;
  17. printf("Dva korena: x1 = %d, x2 = %d", x1, x2);
  18. } else {
  19. re = -b /(2*a);
  20. d = b*b - 4*a*c;
  21. im = sqrt(fabs(d) / 2*a);
  22. if (d > 0) {
  23. x1 = re + im;
  24. x2 = re - im;
  25. printf("Dva korena: x1 = %d, x2 = %d", x1, x2);
  26. } else if (d < 0) {
  27. printf ("(%d, %d) i (%d, %d)", re, im, re, -im);
  28. } else {
  29. x1 = re;
  30. x2 = x1;
  31. printf("Dve ravni korena x1 = x2 = %d", x1);
  32. }
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement