Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <stdio.h>
- #include <conio.h>
- int main()
- {
- int a, b, c;
- float x1, x2, d, re, img;
- printf("Vavedete a: ");
- scanf_s("%d", &a);
- printf("Vavedete b: ");
- scanf_s("%d", &b);
- printf("Vavedete c: ");
- scanf_s("%d", &c);
- d = (b*b) - (4 * a*c);
- if (a == 0)
- {
- if (b == 0)
- {
- if (c == 0)
- {
- printf("Vsichki chisla sa koreni ");
- }
- else
- {
- printf("Nqma reshenie ");
- }
- }
- else
- {
- if (c == 0)
- {
- printf("Korenut e raven na 0 ");
- }
- else
- {
- x1 = (float) (-c) / b;
- printf("Edinstevniqt koren e %f", x1);
- }
- }
- _getche();
- }
- else
- {
- if (d < 0)
- {
- re = (float)(-b / (2 * a));
- img = (float)(sqrt(-d) / (2 * a));
- printf("x1=%.2f+i*%.2f\nx2=%.2f-i*%.2f", re, img, re, img);
- }
- else
- if (d == 0)
- {
- x1 = (float) (-b) / 2 * a;
- printf("Edinstveniqt koren e %f ", x1);
- }
- else
- {
- x1 = (float)(-b + sqrt(d)) / (2 * a);
- x2 = (float)(-b - sqrt(d)) / (2 * a);
- printf("Korenite sa %f,%f", x1, x2);
- }
- _getche();
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement