Pagini recente » Cod sursa (job #3038687) | Cod sursa (job #2724110) | Cod sursa (job #2755774)
#include <iostream>
#include <fstream>
#include <set>
#include <math.h>
using namespace std;
set<pair<int, int>> puncte;
bool check(pair<int, int> a, pair<int, int> b) {
int dy = b.first - a.first, dx = a.second - b.second;
return (puncte.find({a.first + dx, a.second + dy}) != puncte.end() && puncte.find({b.first + dx, b.second + dy}) != puncte.end());
}
int rotunjire(float x) { return round(x * 10000); }
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(rotunjire(a), rotunjire(b)));
}
for(auto i: puncte)
for(auto j: puncte)
if(i != j)
nr += check(i, j);
out << nr / 4;
return 0;
}