Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5. float licz();
  6. int main()
  7. {
  8.  
  9. licz();
  10.  
  11. }
  12.  
  13. float licz()
  14. {
  15. float a,b,c;
  16. cout << "Podaj a" <<endl;
  17. cin >> a;
  18. cout << "Podaj b" <<endl;
  19. cin >> b;
  20. cout << "Podaj c" <<endl;
  21. cin >> c;
  22.  
  23.  
  24. float delta= (b*b - (4*a)*c);
  25.  
  26.  
  27. if (delta>0)
  28. {
  29. float x1= ((-b)-sqrt(delta))/(2*a);
  30. float x2= ((-b)+sqrt(delta))/(2*a);
  31. cout << " X1 ="<< x1 <<endl<< "X2 = " << x2 <<endl;
  32. }
  33. else if(delta=0)
  34. {
  35. float x= ((-b)-sqrt(delta))/(2*a);
  36. cout << " X ="<< x <<endl;
  37.  
  38. }
  39. else if(delta<0)
  40. {
  41. cout << "Nie ma rozwiazań."<<endl;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement