SHARE
TWEET

Untitled

a guest Oct 16th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     double a, b, c, delta, x1, x2;
  10.     cout << "Wprowadz wspolczynniki a, b, c postaci ogolnej rownania kwadratowego\n";
  11.     cin >> a;
  12.     cin >> b;
  13.     cin >> c;
  14.  
  15.     delta = b * b - (4 * a * c); // obliczamy delte
  16.    
  17.     if (delta > 0) //jesli delta wieksza od zera to liczymy delte i pierwiastki
  18.     {
  19.         cout << "Delta > 0\n";
  20.         x1 = (-b - sqrt(delta)) / (2 * a);
  21.         x2 = (-b + sqrt(delta)) / (2 * a);
  22.        
  23.         cout << "x1 = " << x1 <<"\nx2 = " << x2 << endl;
  24.     }
  25.    
  26.     else if (delta == 0) //jesli delta rowna zero to liczymy pierwiastek i wypisujemy
  27.     {
  28.         cout << "Delta = 0\n";
  29.         x1 = -b / (2 * a);
  30.         cout << "x1 = " << x1 << endl;
  31.     }
  32.    
  33.     else
  34.     {
  35.         cout << "Brak pierwiastkow rzeczywistych\n"; //jesli delta mniejsza od zera to wypisujemy, ze nie ma pierwiastkow rzeczywistych
  36.     }
  37.    
  38.     return 0;
  39. }
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