Pagini recente » Cod sursa (job #1059611) | Cod sursa (job #2976964) | Cod sursa (job #2185300) | Cod sursa (job #1075247) | Cod sursa (job #27153)
Cod sursa(job #27153)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <map>
using namespace std;
#define nmax 1024
struct par
{
long x,y;
};
map<par,int> H;
int n,i,j,sol;
par a,b,c,d,v[nmax];
char s[128];
float round(float x)
{
if (x-floor(x)>ceil(x)-x)
return ceil(x);
return floor(x);
}
bool operator < (const par &A, const par &B)
{
if (A.x != B.x)
return A.x < B.x;
return A.y < B.y;
}
int main()
{
freopen("patrate3.in","r",stdin);
freopen("patrate3.out","w",stdout);
scanf("%d\n",&n);
for (i=0;i<n;i++)
{
scanf("%s",s);
v[i].x=0;
for (j=0;j<strlen(s);j++)
if (s[j]!='.')
v[i].x=v[i].x*10+s[j]-'0';
scanf("%s",s);
v[i].y=0;
for (j=0;j<strlen(s);j++)
if (s[j]!='.')
v[i].y=v[i].y*10+s[j]-'0';
/* scanf("%lf %lf\n",&v[i].x,&v[i].y);
v[i].x*=10000;
v[i].y*=10000;
v[i].x=round(v[i].x);
v[i].y=round(v[i].y);*/
H[v[i]]=1;
}
for (i=0;i<n;i++)
for (j=i+1;j<n;j++)
{
a=v[i],b=v[j];
c.x=b.x+a.y-b.y,c.y=b.y+b.x-a.x;
d.x=a.y+a.x-b.y,d.y=b.x+a.y-a.x;
if ((H[c]==1)&&(H[d]==1))
++sol;
/* c.x=b.x+b.y-a.y,c.y=b.y+a.x-b.x;
d.x=b.y+a.x-a.y,d.y=a.x+a.y-b.x;
if ((H[c]==1)&&(H[d]==1))
++sol;*/
}
printf("%d\n",sol/2);
return 0;
}