Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- struct otrezok
- {
- double x, y;
- double length;
- };
- struct direct
- {
- double k = 0, b = 0;
- double parametr = INT32_MAX;
- };
- struct vershina
- {
- double x, y;
- };
- direct stright(vershina one, double k)
- {
- direct stright;
- if (k != INT32_MAX)
- {
- stright.k = k;
- stright.b = one.y - stright.k*one.x;
- }
- else stright.parametr = one.x;
- return stright;
- }
- double sozdanie(double a, double b, double c)
- {
- double itog;
- double cos_itog = (b*b + c*c - a*a)/2/b/c;
- double sin_itog = sqrt(1 - cos_itog*cos_itog);
- double tg_itog;
- if (cos_itog != 0)
- tg_itog = sin_itog/cos_itog;
- else tg_itog = INT32_MAX;
- return tg_itog;
- }
- vershina otvet (direct normal_1, direct normal_2)
- {
- //cout << normal_1.k << "x + " << normal_1.b << " " << normal_1.parametr << endl;
- vershina otvet;
- if (normal_1.parametr == INT32_MAX && normal_2.parametr == INT32_MAX)
- {
- otvet.x = (normal_2.b - normal_1.b)/(normal_1.k - normal_2.k);
- otvet.y = normal_1.k*otvet.x + normal_1.b;
- }
- else if (normal_1.parametr != INT32_MAX)
- {
- otvet.x = normal_1.parametr;
- otvet.y = normal_2.k*otvet.x + normal_2.b;
- }
- else if (normal_2.parametr != INT32_MAX)
- {
- otvet.x = normal_2.parametr;
- otvet.y = normal_1.k*otvet.x + normal_1.b;
- }
- return otvet;
- };
- int main ()
- {
- direct BC, AC;
- vershina A, B, C;
- double a, b, c, dlina_AB, dlina_BC, dlina_AC;
- cin >> dlina_AB >> dlina_AC >> dlina_BC;
- A.x = 0;
- A.y = 0;
- B.x = dlina_AB;
- B.y = 0;
- double tg_A = sozdanie( dlina_BC, dlina_AB, dlina_AC);
- double tg_B = sozdanie( dlina_AC, dlina_BC, dlina_AB);
- if (tg_B != INT32_MAX)
- tg_B = -tg_B;
- AC = stright(A, tg_A);
- BC = stright(B, tg_B);
- C = otvet(AC, BC);
- cout.precision(10);
- cout << fixed << A.x << " " << A.y << endl;
- cout << fixed << B.x << " " << B.y << endl;
- cout << fixed << C.x << " " << C.y << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement