Advertisement
eerrtt

z6

Nov 14th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9. int a, b, c, d;
  10.  
  11. cout << "Podaj a: ";
  12. cin >> a;
  13. if(a == 0){
  14. cout << "Blad, a musi byc rozne od zera (gdy a=0 bedzie to funkcja liniowa a nie kwadratowa)" << endl;
  15. return 0;
  16. }
  17.  
  18. cout << "Podaj b: ";
  19. cin >> b;
  20. cout << "Podaj c: ";
  21. cin >> c;
  22.  
  23. d = b*b-4*a*c;
  24. if(d == 0){
  25. cout << "delta = 0, jedno miejsce zerowe:" << endl;
  26. float x = (-b)/(2*a);
  27. cout << "x = " << x;
  28.  
  29. } else if(d > 0){
  30. cout << "delta > 0, dwa miejsca zerowe:" << endl;
  31. float x1, x2;
  32. x1 = (-b-sqrt(d))/(2*a);
  33. x2 = (-b+sqrt(d))/(2*a);
  34. cout << "x1 = " << x1 << endl;
  35. cout << "x2 = " << x2 << endl;
  36. } else if(d < 0) {
  37. cout << "delta < 0, brak miejsc zerowych:" << endl;
  38. }
  39.  
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement