Pagini recente » Cod sursa (job #3251584) | Cod sursa (job #3273270) | Cod sursa (job #2494309) | Cod sursa (job #3287209) | Cod sursa (job #2752133)
#include <fstream>
#include <cmath>
#define NMax 1005
#include <set>
using namespace std;
ifstream fin("patrate3.in");
ofstream fout("patrate3.out");
set<pair <int, int>> coordinates; ///coordonatele punctelor
pair<int, int> a[NMax];
bool VerificPatrat(pair <int, int> a, pair<int, int> b)
{
int x, y;
y = b.first - a.first, x = a.second - b.second;
if (coordinates.find({ a.first + x, a.second + y }) != coordinates.end())
if(coordinates.find({ b.first + x, b.second + y }) != coordinates.end()) //cautam latura paralela
return 1;
return 0;
}
int main()
{
int i, j, N, rasp = 0;
double x, y;
fin >> N;
for (i = 1; i <= N; ++i)
{
fin >> x >> y;
x *= 10000, y *= 10000;
a[i].first = round(x), a[i].second = round(y);
coordinates.insert(a[i]);
}
for (i = 1; i <= N; ++i)
for (j = 1; j <= N; ++j)
if (i != j && VerificPatrat(a[i], a[j])) ///va fi numarat de 4 ori pt ca face pt fiecare latura
rasp++;
fout << rasp / 4;
return 0;
}