Pagini recente » Cod sursa (job #2423109) | Cod sursa (job #548671) | Cod sursa (job #1449977) | Cod sursa (job #2491765) | Cod sursa (job #2658960)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const double INF=2.0e9;
class POINT
{
private:
int x,y;
public:
POINT()
{
x=y=0;
}
POINT(int x0,int y0)
{
x=x0;
y=y0;
}
void setxy(int x0,int y0)
{
x=x0;
y=y0;
}
int getx()
{
return x;
}
int gety()
{
return y;
}
friend double panta(POINT a,POINT b)
{
if(fabs(a.x-b.x)==0)
return INF;
return (1.0*(b.y-a.y))/(1.0*(b.x-a.x));
}
};
ifstream fin("trapez.in");
ofstream fout("trapez.out");
vector<POINT>v;
vector<double>p;
int main()
{
int n,i,x0,y0,j,k=0;
double m;
POINT temp;
fin>>n;
for(i=1;i<=n;i++)
{
fin>>x0>>y0;
temp.setxy(x0,y0);
v.push_back(temp);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
m=panta(v[i],v[j]);
p.push_back(m);
}
}
sort(p.begin(),p.end());
for(i=0;i<p.size()-1;i++)
if(p[i]==p[i+1])
k++;
fout<<k;
return 0;
}