Pagini recente » Cod sursa (job #2591014) | Cod sursa (job #2683231) | Cod sursa (job #3149838) | Cod sursa (job #1459827) | Cod sursa (job #2771700)
#include<iostream>
#include<fstream>
#include<set>
#include<cmath>
using namespace std;
ifstream cit("patrate3.in");
ofstream afis("patrate3.out");
int main()
{
set<pair<int, int>> perechi;
pair<int, int> coord[1001];
int N, x1, x2, x3, x4, y1, y2, y3, y4, nr_pat = 0;
double x, y;
cit>>N;
for(int i = 0; i < N; i++){
cit>>x>>y;
coord[i].first = round(x * 10000);
coord[i].second = round(y * 10000);
perechi.insert(coord[i]);
}
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(i != j){
x1 = coord[i].first;
y1 = coord[i].second;
x2 = coord[j].first;
y2 = coord[j].second;
x3 = y1 - y2 + x1;
y3 = x2 - x1 + y1;
x4 = y1 - y2 + x2;
y4 = x2 - x1 + y2;
if((perechi.find({x3, y3}) != perechi.end()) && (perechi.find({x4, y4}) != perechi.end())){
nr_pat++;
}
}
}
}
afis<<nr_pat/4;
return 0;
}