Advertisement
Guest User

adamm

a guest
Jan 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include <cstdlib>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. double a, b, c, delta, x1, x2;
  12. int wybor = 1;
  13. while (wybor)
  14. {
  15. system("cls");
  16. cout << "Program Liczy miejsca zerowe rownan kwadratowych" << endl;
  17. cout << "Podaj wspolczynniki a, b oraz c" << endl;
  18. cout << "Zamiast przecinka uzyj kropki" << endl;
  19. cin >> a >> b >> c;
  20. //cin >> b;
  21. //cin >> c;
  22. system("cls"); //czysci okienko cmd//
  23.  
  24.  
  25. if (a == 0)
  26. {
  27. if (b != 0)
  28. {
  29. cout << "to nie rownanie kwadratowe, tylko liniowe, miejsce zerowe wynosi: ";
  30. x1 = x2 = -c / b;
  31. cout << x1 << endl;
  32. }
  33.  
  34. else if ((b == 0) && (c == 0))
  35. {
  36. cout << "Rownanie ma nieskoczenie wiele rozwiazan" << endl;
  37. }
  38.  
  39. else
  40. {
  41. cout << "brak rozwiazan" << endl;
  42. }
  43. }
  44. else
  45. {
  46. delta = b * b - 4 * a*c;
  47.  
  48. if (delta > 0)
  49. {
  50. x1 = (-b - sqrt(delta)) / 2 * a;
  51. x2 = (-b + sqrt(delta)) / 2 * a;
  52. cout << "x1=" << x1 << " x2=" << x2 << endl;
  53. }
  54. else if (delta == 0)
  55. {
  56. x1 = -b / 2 * a;
  57. cout << "x1=" << x1 << endl;
  58. }
  59. else
  60. {
  61. cout << "delta ujemna brak miejsc zerowych :/" << endl;
  62. }
  63.  
  64. }
  65. cout << "chcesz jewszcze raz? [0/1]" << endl;
  66. do {
  67. cin.clear();
  68. cin >> wybor;
  69. }
  70. while (wybor != 1);
  71.  
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement