Facebook
From ja, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 206
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     float a,b,c;
  10.     float x1,x2,x0;
  11.     float delta;
  12.     cin>>a;
  13.     cin>>b;
  14.     cin>>c;
  15.     if(a==0){
  16.         cout<<"to nie jest trojmian kwadratowy"<<endl;
  17.     }
  18.     else{
  19.         delta=b*b-4*a*c;
  20.         if(delta>0){
  21.             x1=(-b-sqrt(delta))/2*a;
  22.             x2=(-b+sqrt(delta))/2*a;
  23.             cout<<"x1="<<x1<<endl<<"x2="<<x2<<endl;
  24.         }else{
  25.         if(delta==0){
  26.             x0=-b/2*a;
  27.             cout<<"x0="<<x0;
  28.         }
  29.             else{
  30.                 cout<<"Nie ma pierwiastkow w zbiorze rzeczywistej";
  31.                 system("pause");
  32.             }
  33.         }
  34.     }system("pause");
  35. }