Advertisement
Guest User

Kv. urav

a guest
Mar 28th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <math.h>
  2. #include <stdio.h>
  3. #include <conio.h>
  4.  
  5. int main()
  6. {
  7. int a, b, c;
  8. float x1, x2, d, re, img;
  9.  
  10.  
  11. printf("Vavedete a: ");
  12. scanf_s("%d", &a);
  13. printf("Vavedete b: ");
  14. scanf_s("%d", &b);
  15. printf("Vavedete c: ");
  16. scanf_s("%d", &c);
  17.  
  18. d = (b*b) - (4 * a*c);
  19.  
  20. if (a == 0)
  21. {
  22.  
  23. if (b == 0)
  24. {
  25. if (c == 0)
  26. {
  27. printf("Vsichki chisla sa koreni ");
  28. }
  29. else
  30. {
  31. printf("Nqma reshenie ");
  32. }
  33.  
  34. }
  35. else
  36. {
  37. if (c == 0)
  38. {
  39. printf("Korenut e raven na 0 ");
  40. }
  41. else
  42. {
  43. x1 = (float) (-c) / b;
  44. printf("Edinstevniqt koren e %f", x1);
  45. }
  46. }
  47. _getche();
  48. }
  49. else
  50. {
  51. if (d < 0)
  52. {
  53. re = (float)(-b / (2 * a));
  54. img = (float)(sqrt(-d) / (2 * a));
  55. printf("x1=%.2f+i*%.2f\nx2=%.2f-i*%.2f", re, img, re, img);
  56. }
  57. else
  58. if (d == 0)
  59. {
  60. x1 = (float) (-b) / 2 * a;
  61. printf("Edinstveniqt koren e %f ", x1);
  62. }
  63. else
  64. {
  65. x1 = (float)(-b + sqrt(d)) / (2 * a);
  66. x2 = (float)(-b - sqrt(d)) / (2 * a);
  67. printf("Korenite sa %f,%f", x1, x2);
  68. }
  69.  
  70. _getche();
  71. return 0;
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement