Pagini recente » Cod sursa (job #2723723) | Cod sursa (job #2691739) | Cod sursa (job #2754996) | Cod sursa (job #2496923) | Cod sursa (job #2755771)
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
using namespace std;
set<pair<float, float>> puncte;
bool check(pair<float, float> a, pair<float, float> b) {
float dy = b.first - a.first, dx = a.second - b.second;
return (puncte.find(make_pair(a.first + dx, a.second + dy)) != puncte.end() && puncte.find(make_pair(b.first + dx, b.second+dy)) != puncte.end());
}
int main()
{
ifstream in ("patrate3.in");
ofstream out ("patrate3.out");
int n, nr = 0;
float a, b;
in >> n;
for(int i = 0; i < n; i++) {
in >> a >> b;
puncte.insert(make_pair(a, b));
}
for(auto i: puncte)
for(auto j: puncte)
nr += check(i, j);
out << nr / 4;
return 0;
}