SHARE
TWEET

Untitled

a guest Feb 18th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     float a,b,c;
  7.     printf("Podaj wspolczynniki rownania ax^2+bx+c=0:\n");
  8.     printf("a=");
  9.     scanf("%f",&a);
  10.     printf("b=");
  11.     scanf("%f",&b);
  12.     printf("c=");
  13.     scanf("%f",&c);
  14.  
  15.     if(a == 0){
  16.         if(b == 0){
  17.             if(c == 0){
  18.                 printf("Rownanie nieoznaczone");
  19.             } else
  20.                 printf("Brak rozwiazan");
  21.         }
  22.          else
  23.             printf("Rownanie liniowe, rozwiazanie: x = %f", -1*c/b);
  24.     } else {
  25.         float delta = b*b-4*a*c;
  26.         if(delta > 0){
  27.             float x1,x2;
  28.             x1 = -b-sqrt(delta) / 2*a;
  29.             x2 = -b+sqrt(delta) / 2*a;
  30.             printf("Pierwiastki wynosza:\nx1 = %f\nx2 = %f\n",x1,x2);
  31.         } else if (delta == 0){
  32.             float x;
  33.             x = -b/2*a;
  34.             printf("Pierwiastek wynosi:\nx = %f\n",x);
  35.         } else {
  36.             printf("Brak pierwiastkow");
  37.         }
  38.     }
  39.  
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top