0% found this document useful (0 votes)
2 views4 pages

1111

The document contains a C++ program that processes geometric patterns and coordinates. It reads input for points and calculates angles and distances between them, attempting to find specific configurations based on certain criteria. The program outputs the coordinates of found patterns and manages memory dynamically for structures representing points and angles.

Uploaded by

S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

1111

The document contains a C++ program that processes geometric patterns and coordinates. It reads input for points and calculates angles and distances between them, attempting to find specific configurations based on certain criteria. The program outputs the coordinates of found patterns and manages memory dynamically for structures representing points and angles.

Uploaded by

S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <iostream>

#include <cmath>
using namespace std;
struct pattern {

int x;
int y;
double dl;

};

struct kucha {
int x;
int y;

};

struct ans {
int x;
int y;

};

int main() {

int vet = 0;
int back[1000][3];
int found = 0;
int n = 0;
int m = 0;
double scal = 0;
double dl1 = 0;
double dl2 = 0;
double tt = 0;
cin >> n;
ans *an = new ans[n];
for (int i = 0; i < n; i++)
{
an[i].x = -100;
an[i].y = -100;
}

pattern *pat = new pattern[n];


double *angle = new double[n - 2];
for (int i = 0; i < n; i++)
{
cin >> pat[i].x >> pat[i].y;
}
cin >> m;
kucha *kuch = new kucha[m];
for (int i = 0; i < m; i++) {
cin >> kuch[i].x >> kuch[i].y;
}

bool endd = 1;

for (int i = 0; i < n - 2; i++) {

scal = (pat[i].x - pat[i + 1].x)*(pat[i + 2].x - pat[i + 1].x) +


(pat[i].y - pat[i + 1].y)*(pat[i + 2].y - pat[i + 1].y);
dl1 = abs(sqrt(((pat[i].x - pat[i + 1].x)*(pat[i].x - pat[i + 1].x)) +
((pat[i].y - pat[i + 1].y)*(pat[i].y - pat[i + 1].y))));
dl2 = abs(sqrt(((pat[i + 2].x - pat[i + 1].x)*(pat[i + 2].x - pat[i +
1].x)) + ((pat[i + 2].y - pat[i + 1].y)*(pat[i + 2].y - pat[i + 1].y))));
tt = scal / (dl1*dl2);
angle[i] = acos(tt)* 57.2958;
}
for (int i = 0; i < n - 1; i++)
{
pat[i].dl = abs(sqrt(((pat[i].x - pat[i + 1].x)*(pat[i].x - pat[i +
1].x)) + ((pat[i].y - pat[i + 1].y)*(pat[i].y - pat[i + 1].y))));

}
int ug = 0;
double ddl = 0;
double ddll = ddl;
again:;
bool rd = 1;
int lastsave1 = -1;
int lastsave2 = -1;
int lastsave3 = -1;
int ff = 0;
bool wtf = 0;
int save1 = -1;
int zap = 0;
int save2 = -1;
int save3 = -1;
for (int i = 0; i < m; i++) {
for (int j = 0; j < m; j++) {
for (int z = 0; z < m; z++) {
if (z != i && z != j && j != i) {

scal = (kuch[i].x - kuch[j].x)*(kuch[z].x -


kuch[j].x) + (kuch[i].y - kuch[j].y)*(kuch[z].y - kuch[j].y);
dl1 = abs(sqrt(((kuch[i].x - kuch[j].x)*(kuch[i].x -
kuch[j].x)) + ((kuch[i].y - kuch[j].y)*(kuch[i].y - kuch[j].y))));
dl2 = abs(sqrt(((kuch[z].x - kuch[j].x)*(kuch[z].x -
kuch[j].x)) + ((kuch[z].y - kuch[j].y)*(kuch[z].y - kuch[j].y))));
tt = scal / (dl1*dl2);
ddll = ddl;

rd = 1;
for (int rt = 0; rt < n; rt++) {
if ((an[rt].x == kuch[z].x) && (an[rt].y ==
kuch[z].y)) {
rd = 0;
}
}
if (pat[found].dl / pat[found + 1].dl>1 &&
pat[found].dl / pat[found + 1].dl<15)ddl = pat[found].dl / pat[found + 1].dl * 0.1;
if ((pat[found].dl / pat[found + 1].dl >= 15)&&
(pat[found].dl / pat[found + 1].dl < 70))ddl = (pat[found].dl / pat[found + 1].dl)
* 0.65;
if ((pat[found].dl / pat[found + 1].dl >= 70))ddl =
(pat[found].dl / pat[found + 1].dl) * 0.8;
if ((rd) && ((acos(tt) * 57.2958) >= angle[found] -
ug) && ((acos(tt)*57.2958) <= angle[found] + ug) && (((dl1 / dl2)) <=
(pat[found].dl / pat[found + 1].dl) + ddl) && (((dl1 / dl2)) >= (pat[found].dl /
pat[found + 1].dl) - ddl)) {

an[found].x = kuch[i].x;
an[found].y = kuch[i].y;
an[found + 1].x = kuch[j].x;
an[found + 1].y = kuch[j].y;
an[found + 2].x = kuch[z].x;
an[found + 2].y = kuch[z].y;
found++;

if (save1 == -1) {
save1 = i;
save2 = j;
save3 = z;
vet = 0;
}
back[vet][0] = i;
back[vet][1] = j;
back[vet][2] = z;
vet++;

i = j;
j = z;
z = 0;

z--;

goto next;
}
else if (((save2 != -1) && (save3 != -1) && ((z == (m
- 1)) || (i != back[vet-1][1]) || (j != back[vet-1][2])))) {

for (int qq = 0; qq < n; qq++) {


an[qq].x = -100;
an[qq].y = -100;
}
found = 0;
vet--;
if (vet >= 0) {
i = back[vet][0];
j = back[vet][1];
z = back[vet][2];
}
else
{
save1 = -1;
save2 = -1;
save3 = -1;
}

/* lastsave1 = save1;
lastsave2 = save2;
lastsave3 = save3;*/
}
next:;

ddl = ddll;
for (int qq = 0; qq < n; qq++) {
if ((an[qq].x == -100) && (an[qq].y == -100)) {
endd = false;
}
}
if (endd)goto point; else endd = 1;
}
}
}
}
for (int i = 0; i < n; i++) {
if (an[i].x == -100) { ddl = ddl + 0.025; ug += 3; goto again; }
}

point:;

for (int i = 0; i < n; i++)


{
cout << an[i].x << " " << an[i].y << endl;
}
delete[]pat;
return 0;
}

You might also like