Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- int a, b, c, x, x1, x2, re, d, im;
- scanf("%d %d %d",&a, &b, &c);
- if (a == 0 && b == 0) {
- printf("Izrodeno uravnenie");
- } else if (a == 0) {
- x = -c / b;
- printf("Lineino uravnenie, x = %d", x);
- } else if (c == 0) {
- x1 = -b / a;
- x2 = 0;
- printf("Dva korena: x1 = %d, x2 = %d", x1, x2);
- } else {
- re = -b /(2*a);
- d = b*b - 4*a*c;
- im = sqrt(fabs(d) / 2*a);
- if (d > 0) {
- x1 = re + im;
- x2 = re - im;
- printf("Dva korena: x1 = %d, x2 = %d", x1, x2);
- } else if (d < 0) {
- printf ("(%d, %d) i (%d, %d)", re, im, re, -im);
- } else {
- x1 = re;
- x2 = x1;
- printf("Dve ravni korena x1 = x2 = %d", x1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement