Pagini recente » Cod sursa (job #1440537) | Cod sursa (job #1504879) | Cod sursa (job #822898) | Cod sursa (job #2472880) | Cod sursa (job #772758)
Cod sursa(job #772758)
#include<fstream>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
int n, i, j, pereche, nr;
long long x[1000], y[1000], lung[500];
int main() {
fin >> n;
for(i = 0; i < n; i++) {
fin >> x[i];
fin >> y[i];
}
fin.close();
for(i = 0; i < n; i++) {
for(j = i + 1; j < n; j++) {
if(x[i] == x[j]) {
if(y[i] > y[j]) {
lung[pereche] = y[i] - y[j];
}else {
lung[pereche] = y[j] - y[i];
}
pereche++;
}
}
}
if(pereche > 1) {
nr = (pereche * (pereche - 1)) / 2;
}
for(i = 0; i < pereche; i++) {
for(j = i + 1; j < pereche; j++) {
if(lung[i] == lung[j]) {
nr++;
}
}
}
pereche = 0;
for(i = 0; i < n; i++) {
for(j = i + 1; j < n; j++) {
if(y[i] == y[j]) {
if(x[i] > x[j]) {
lung[pereche] = x[i] - x[j];
}else {
lung[pereche] = x[j] - x[i];
}
pereche++;
}
}
}
if(pereche > 1) {
nr += (pereche * (pereche - 1)) / 2;
}
for(i = 0; i < pereche; i++) {
for(j = i + 1; j < pereche; j++) {
if(lung[i] == lung[j]) {
nr++;
}
}
}
fout << nr;
fout.close();
return 0;
}