Advertisement
pan7nikt

zad_1_5

Oct 9th, 2023
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     float a,b,c = 0;
  9.     float x1 = 0;
  10.     float x2 = 0;
  11.     float delta = 0;
  12.    
  13.    
  14.     cout << "Podaj a: ";
  15.     cin >> a;
  16.     cout << "\nPodaj b: ";
  17.     cin >> b;
  18.     cout << "\nPodaj c: ";
  19.     cin >> c;
  20.    
  21.     //ax^2 + bx + c = 0
  22.     //bx + c = 0
  23.     //bx = 0-c
  24.     //x = (0-c)/b
  25.     if(a == 0)
  26.     {
  27.         x = (-1*c)/b;
  28.     }
  29.     else
  30.     {
  31.         delta = (-1*b)^2 - (4 * a * c);
  32.         if(delta > 0)
  33.         {
  34.             x1 = (-1*b - sqrt(delta)) / (2*a);
  35.             x2 = (-b + sqrt(delta)) / (2*a);
  36.         }
  37.         if(delta == 0)
  38.         {
  39.             x = (-b)/(2*a);
  40.         }
  41.         if()
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement