• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Dec 5th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <cmath>
3.
4. void bsqrmin4ac(double a, double b, double c);
5. double posovr2a(double sqrtd, int a, int b);
6. double negovr2a(double sqrtd, int a, int b);
7. void zerodet(double a2, double b2);
8. void posdet(double d, double a2, double b2);
9.
10. int main()
11. {
12.     std::cout << "Hello there uwu uwu uwu\n";
13.     double a {};
14.     double b {};
15.     double c {};
16.     std::cout << "enter a: " << "\n";
17.         std::cin >> a;
18.     std::cout << "enter b: " << "\n";
19.         std::cin >> b;
20.     std::cout << "enter c: " << "\n";
21.         std::cin >> c;
22.     bsqrmin4ac(a,b,c);
23.     return 0;
24. }
25.
26. void bsqrmin4ac(double a, double b, double c)
27. {
28.     double a2{ a };
29.     double b2{ b };
30.     double d{ (b * b) - (4 * a * c) };
31.
32.     if (d < 0)
33.         std::cout << "We do not support negative determinant, shoo before Putin arrests you...";
34.     if (d > 0)
35.         posdet(d, a2, b2);
36.     if (d == 0)
37.         zerodet(a2, b2);
38. }
39.
40. double posovr2a(double sqrtd, double a, double b)
41. {
42.     double h{ ((0 - b) + sqrtd) / (2*a) };
43.     return h;
44. }
45.
46. double negovr2a(double sqrtd, double a, double b)
47. {
48.     double f{ ((0 - b) - sqrtd )/ (2*a) };
49.     return f;
50. }
51.
52. void posdet(double d, double a2, double b2)
53. {
54.     double sqrtd{ sqrt(d) };
55.     double ans1{ posovr2a(sqrtd, a2, b2) };
56.     double ans2{ negovr2a(sqrtd, a2 ,b2) };
57.     std::cout << "x1: " << ans1 << "\n";
58.     std::cout << "x2: " << ans2 << "\n";
59. }
60.
61. void zerodet(double a2, double b2)
62. {
63.     double m{ (0 - b2) / (2 * a2) };
64.     std::cout << "zero determinant: " << m << "\n";
65. }
66.
67. //sanity check, ignore
68. /*
69. int main()
70. {
71.     double s{};
72.     std::cin >> s;
73.     double f{ sqrt(s) };
74.     std::cout << f;
75.     return 0;
76. }*/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?