Don't like ads? PRO users don't see any ads ;-)
Guest

progrom1

By: a guest on Apr 25th, 2012  |  syntax: C++  |  size: 0.46 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6.         float x1,x2,a,b,c,delta,x0;
  7.         cout<<"podaj a,b,c"<<endl;
  8.         cin>>a>>b>>c;
  9.         delta=(b*b-4*a*c);
  10.         cout<<"delta="<<delta<<endl;
  11.         if (delta>=1)
  12.         {
  13.         x1=(-b-sqrt(delta)/2*a);
  14.         x2=(-b+sqrt(delta)/2*a);
  15.         cout<<"x1="<<x1<<endl;
  16.         cout<<"x2="<<x2<<endl;
  17.         }
  18.         if (delta<1)
  19.         {
  20.                 cout<<"delta jest ujemna"<<endl;
  21.         }
  22.         if (delta==0)
  23.         {
  24.                 x0=(-b/2*a);
  25.                 cout<<"x0="<<x0<<endl;
  26.         }
  27.                
  28.        
  29.        
  30.  
  31. }