Pagini recente » Cod sursa (job #2445338) | Cod sursa (job #1418025) | Cod sursa (job #2595330) | Cod sursa (job #3177083) | Cod sursa (job #3285994)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
const int MAXN = 1e3 + 5;
int N, ans;
struct point {
int x;
double y;
// bool operator < (point& a) const {
// if ( x )
// }
} puncte[MAXN];
struct line
{
point a, b;
double slope;
}lines[MAXN];
int main () {
fin >> N;
int k = 1;
ans = 0;
for ( int i = 1; i <= N; ++ i ) {
fin >> puncte[i].x >> puncte[i].y;
}
for ( int i = 1; i < N; ++ i ) {
for ( int j = i + 1; j <= N; ++ j ) {
point a = puncte[i];
point b = puncte[j];
lines[k].a = a;
lines[k].b = b;
lines[k].slope = (b.y - a.y)/(b.x - a.x);
k ++;
}
}
k --;
// for ( int i = 1; i <= k; ++ i ) {
// fout << lines[i].a.x << ", " <<lines[i].a.y << " " << lines[i].b.x << ", " << lines[i].b.y << " " << lines[i].slope << '\n';
// }
for ( int i = 1; i < k; ++ i ) {
for ( int j = i + 1; j <= k; ++ j ) {
if ( lines[i].slope == lines[j].slope ) ans ++;
}
}
fout << ans;
}