Pagini recente » Cod sursa (job #340947) | Cod sursa (job #550198) | Cod sursa (job #2837131) | Cod sursa (job #415882) | Cod sursa (job #2755852)
#include <iostream>
#include <fstream>
#include <set>
#include <cmath>
using namespace std;
ifstream f("patrate3.in");
ofstream g("patrate3.out");
struct punct
{
int x,y;
};
pair <int, int> v[1001];
set<pair <int, int> > s;
bool estePatrat(pair <int, int> A, pair <int, int> B){
int dx = A.first - B.first, dy = B.second - A.second;
if(s.find({A.first + dy, A.second + dx}) != s.end())
if(s.find({B.first + dy, B.second + dx}) != s.end())
return true;
return false;
}
int main()
{
int n, c=0;
double xx, yy;
f >> n;
for(int i = 1; i <= n; i++)
{
f >> xx >> yy;
v[i].first = round(xx * 10000);
v[i].second = round(yy * 10000);
s.insert(v[i]);
}
for(int i = 1; i <= n ; i++)
for(int j = 1 ; j <= n ; j++)
if(i != j && estePatrat(v[i], v[j]))
c++;
g << c / 4;
return 0;
}