Pagini recente » Cod sursa (job #1256644) | Cod sursa (job #2010242) | Cod sursa (job #3164464) | Cod sursa (job #1097659) | Cod sursa (job #1576712)
#include<fstream>
#include<algorithm>
using namespace std;
ifstream f("trapez.in");
ofstream g("trapez.out");
int n,i,j,solutie,nr,z=1,INFINIT=200002;
struct trapez
{
int x;
int y;
}v[1002];
double panta[1000005];
int main()
{
f>>n;
for(i=1; i<=n; i++)
f>>v[i].x>>v[i].y;
for(i=1; i<=n; i++)
for(j=i+1; j<=n; j++)
if(v[i].x==v[j].x)
{
panta[++nr]=INFINIT;
}
else
{
panta[++nr]=double(v[i].y-v[j].y)/(v[j].x-v[i].x);
}
sort(panta+1,panta+nr+1);
for(i=2; i<=nr; i++)
{
if(panta[i]==panta[i-1])
{
z++;
}
else
{
solutie=solutie+z*(z-1)/2;
z=1;
}
}
solutie=solutie+z*(z-1)/2;
g<<solutie;
f.close();
g.close();
return 0;
}