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 x1, y1, x2, y2;
- double length;
- void dlina (double x, double y, double x2_1, double y2_1)
- {
- x1 = x;
- y1 = y;
- x2 = x2_1;
- y2 = y2_1;
- length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
- }
- };
- struct vershina
- {
- double x, y;
- };
- struct direct
- {
- double a = 0, b = 0;
- double parametr = 0;
- };
- otrezok sozdanie(vershina one, vershina two)
- {
- otrezok a;
- a.dlina(one.x, one.y, two.x, two.y);
- return a;
- }
- direct result(vershina one, vershina two)
- {
- direct stright;
- if(two.x - one.x != 0)
- {
- stright.a = (one.y - two.y)/(one.x - two.x);
- stright.b = one.y - stright.a*one.x;
- }
- else stright.parametr = one.x;
- return stright;
- }
- vershina point (vershina one, vershina two, otrezok left, otrezok right, otrezok a)
- {
- vershina point_bissek;
- double m = left.length*a.length/(right.length+left.length);
- double n = a.length - m;
- point_bissek.x = (n*one.x+m*two.x)/(n+m);
- point_bissek.y = (n*one.y+m*two.y)/(n+m);
- //cout << point_bissek.x << " " << point_bissek.y << endl;
- return point_bissek;
- }
- vershina otvet (direct bissek_1, direct bissek_2)
- {
- vershina otvet;
- if (bissek_1.parametr == 0 && bissek_2.parametr == 0)
- {
- otvet.x = (bissek_2.b - bissek_1.b)/(bissek_1.a - bissek_2.a);
- otvet.y = bissek_1.a*otvet.x + bissek_1.b;
- }
- else if (bissek_1.parametr != 0)
- {
- otvet.x = bissek_1.parametr;
- otvet.y = bissek_2.a*otvet.x + bissek_2.b;
- }
- else
- {
- otvet.x = bissek_2.parametr;
- otvet.y = bissek_1.a*otvet.x + bissek_1.b;
- }
- return otvet;
- };
- int main ()
- {
- vershina A, B, C;
- cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
- otrezok *arr = new otrezok[3];
- arr[0] = sozdanie(A, B);
- arr[1] = sozdanie(B, C);
- arr[2] = sozdanie(A, C);
- vershina peresech_AB = point(A, B, arr[2], arr[1], arr[0]);
- vershina peresech_BC = point(B, C, arr[0], arr[2], arr[1]);
- direct bissek_A = result(A, peresech_BC);
- direct bissek_C = result(C, peresech_AB);
- cout.precision(6);
- cout << fixed << otvet(bissek_A, bissek_C).x << " ";
- cout << fixed << otvet(bissek_A, bissek_C).y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement