Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     double a, b, c, delta, x, x1, x2;
  7.  
  8.     printf("Wprowadz wspolczynniki a, b oraz c: ");
  9.     scanf("%lf %lf %lf",&a, &b, &c);
  10.  
  11.     if(a==0)
  12.     {
  13.         x = (c/b);
  14.         printf("x = %lf \n", x);
  15.         exit(0);
  16.     }
  17.  
  18.     delta = b*b-4*a*c;
  19.  
  20.     printf("Delta wynosi: %lf \n", delta);
  21.  
  22.     if(delta > 0)
  23.     {
  24.         x1 = (-b+sqrt(delta))/(2*a);
  25.         x2 = (-b-sqrt(delta))/(2*a);
  26.         printf("x1 = %.2lf oraz x2 = %.2lf \n", x1, x2);
  27.     }
  28.     else if (delta == 0)
  29.     {
  30.         x1 = x2 = -b/(2*a);
  31.         printf("x1 = x2 = %.2lf \n", x1);
  32.     }
  33.     else
  34.     {
  35.         printf("Brak rozwiazań w ciele liczb rzeczywistych.");
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement