Pagini recente » Cod sursa (job #2859507) | Cod sursa (job #276861) | Cod sursa (job #2407281) | Cod sursa (job #496367) | Cod sursa (job #1226446)
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#define INF 1.e9
#define eps 1.e-14;
using namespace std;
class POINT
{
private:
double x,y;
public:
POINT(){x=y=0;}
void set(double x0,double y0){x=x0,y=y0;}
bool vertical(const POINT &other){return x==other.x;}
double panta(const POINT &other){if(vertical(other))return INF;return (other.y-y)/(other.x-x); }
};
vector <double> pan;
POINT a[1010];
int main()
{
int n,i,j,sum=0,nr=0;
double last,x,y;
freopen("trapez.in","r",stdin);
freopen("trapez.out","w",stdout);
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%lf%lf",&x,&y);
a[i].set(x,y);
}
for(i=1; i<n; i++)
for(j=i+1; j<=n; j++)
pan.push_back(a[i].panta(a[j]));
sort(pan.begin(),pan.end());
last=pan[0];
nr=1;
for(i=1; i<=pan.size()-1; i++)
if(last==pan[i])
nr++;
else
{
if(nr>1)
sum+=(nr*(nr-1)/2);
nr=1;
last=pan[i];
}
printf("%d\n",sum);
return 0;
}