Pagini recente » Cod sursa (job #302421) | Cod sursa (job #74752) | Cod sursa (job #745755) | Cod sursa (job #1211846) | Cod sursa (job #583939)
Cod sursa(job #583939)
#include <fstream>
#include <algorithm>
#define paralel 66634
using namespace std;
int n,seg,nrt;
struct p{int x,y;};
p a[1003];
struct dr{int A,B;float panta;};
dr b[40003];
int main()
{
int i,j;
ifstream in("trapez.in");
in>>n;
for(i=0;i<n;i++)
in>>a[i].x>>a[i].y;
in.close();
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
b[seg].A=i;
b[seg].B=j;
if(a[i].x!=a[j].x)
b[seg].panta=(float)(a[i].y-a[j].y)/(a[i].x-a[j].x);
else b[seg].panta=paralel;
seg++;
}
for(i=0;i<seg;i++)
for(j=i+1;j<seg;j++)
if(b[i].panta==b[j].panta)
nrt++;
ofstream out("trapez.out");
out<<nrt<<'\n';
return 0;
}