Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <vcl.h>
  2. #include <iostream.h>
  3. #include <conio.h>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int a,b,c,x;
  11. double x1,x2;
  12.  
  13. cout << "Program liczy pierwiastki kwadratowe rownania" << endl;
  14.  
  15.     cout << "Podaj a:" << endl;
  16.     cin >> a;
  17.  
  18.     cout << endl;
  19.  
  20.     cout << "Podaj b:" << endl;
  21.     cin >> b;
  22.  
  23.     cout << endl;
  24.  
  25.     cout << "Podaj c:" << endl;
  26.     cin >> c;
  27.  
  28.     cout << endl;
  29.  
  30.     cout << "Rownanie ma postac y = " << a << "x^2 + " << b << "x + " << c << endl;
  31.     cout << endl;
  32.    
  33.     int delta = (b^2)-4*a*c;
  34.  
  35.     if (delta<0)
  36.         {
  37.         cout << "Delta < 0, wiec brak pierwiastkow rzeczywistych rownania!" << endl;
  38.         getch();
  39.         return 0;
  40.         }
  41.        
  42.     if (delta>0)
  43.  
  44.     cout << "Pierwiastki rownania kwadratowego to:" << endl;
  45.  
  46.     cout << "x1 = " << (-b-(sqrt(delta)))/(2*a) << endl;
  47.     cout << "x2 = " << (-b+(sqrt(delta)))/(2*a) << endl;
  48.  
  49.  
  50.     getch();
  51.     return 0;
  52. }
Add Comment
Please, Sign In to add comment