SHARE
TWEET

Untitled

a guest Oct 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void zad3()
  2. {
  3.     double a, b, c, x1, x2, x0, delta;
  4.  
  5.     cout<<"Podaj współczynniki a, b i c: ";
  6.     cin>>a>>b>>c;
  7.  
  8.     delta = b*b - 4*a*c;
  9.  
  10.     if(delta>0) //jeśli delta jest większa od 0 to mamy dwa miejsca zerowe
  11.     {
  12.         delta = sqrt(delta); //wyznaczamy pieriwastek z delty
  13.         x1 = (-b - delta)/(2*a);
  14.         x2 = (-b + delta)/(2*a);
  15.         cout<<"Są dwa pierwiastki równania: "<<fixed<<setprecision(2)<<x1<<" "<<x2;
  16.     }
  17.     else
  18.         if(delta==0)
  19.         {
  20.             x0 = -b/(2*a);
  21.             cout<<"Jest jeden pierwiastek: "<<fixed<<setprecision(2)<<x0;
  22.         }
  23.         else
  24.             cout<<"Brak pierwiastków";
  25. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top