Advertisement
STANAANDREY

ex1

Jan 18th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 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,delta,x1,x2;
  9.  
  10.  do {
  11.  cout<<"a=";cin>>a;
  12.  } while (!a);//
  13.  cout<<"b=";cin>>b;
  14.  cout<<"c=";cin>>c;
  15.  
  16.  delta=(b*b-4*a*c);
  17.  if (delta>=0)  {
  18.    delta=sqrt(delta);    
  19.  x1=(-b+delta)/(2*a);//*/
  20. x2=(-b-delta)/(2*a);
  21. cout<<"x1="<<x1<<endl;
  22. cout<<"x2="<<x2<<endl;
  23.  }
  24.  else
  25.     cout<<"ecuatia nu are solutii";
  26.  
  27.  return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement