Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // x^2 - 6*x + 7 = 0
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5. using namespace std;
  6. int main()
  7. {
  8. setlocale(LC_ALL, "rus");
  9.  
  10. float x, D, a, b, c, x1, x2;
  11. cout << "Введите первое число" << endl;
  12. cin >> a;
  13. cout << "Введите второе число" << endl;
  14. cin >> b;
  15. cout << "Введите третье число" << endl;
  16. cin >> c;
  17.  
  18. D = b * b - 4 * a*c;
  19. cout << "D = " << D << endl;
  20. if (D > 0);
  21. {
  22. cout << "Ищем x1" << endl;
  23. std::cout << "sqrt(" << D << ") = "
  24. << sqrt(D)
  25. << std::endl;
  26. x1 = (-b + sqrt(D)) / 2 * a;
  27. cout << "x1 =" << x1 << endl;
  28. x2 = (-b - sqrt(D)) / 2 * a;
  29. cout << "x2 =" << x2 << endl;
  30. }
  31. /*
  32. else {
  33. cout << "Нет решения" << endl;
  34. }
  35. */
  36.  
  37. system ("pause");
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement