Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define _USE_MATH_DEFINES // w bibliotece <math.h> Microsoftu
- #include <math.h> // funkcja matematyczna pierwiastka: sqrt
- int main()
- {
- double a, b, c, delta, x1, x2;
- printf("Podaj pierwsza liczbe A= ");
- scanf("%lf", &a);
- printf("Podaj druga liczbe B= ");
- scanf("%lf", &b);
- printf("Podaj trzecia liczbe C= ");
- scanf("%lf", &c);
- delta = b*b - 4 * a*c;
- if (delta < 0)
- printf("\n Brak rozwiazan");
- else
- if (delta == 0)
- {
- x1 = x2 = -b / (2 * a);
- printf("Jest jedno rozwiazanie x1=x2= %f", x1);
- }
- else
- {
- x1 = (-b - sqrt(delta)) / (2 * a);
- x2 = (-b + sqrt(delta)) / (2*a);
- printf("Sa dwa rozwiazania x1= %.2f, x2= %.2f", x1, x2);
- }
- printf("\n\n Nacisnij ENTER, aby zakonczyc program");
- fflush(stdin);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement