Pagini recente » Cod sursa (job #1670761) | Cod sursa (job #2098704) | Cod sursa (job #222311) | Cod sursa (job #2558673) | Cod sursa (job #1510505)
#include <bits/stdc++.h>
using namespace std;
ifstream in("trapez.in");
ofstream out("trapez.out");
int n;
struct point{int x,y;};
point *points;
struct line{point A,B;};
line *lines;
int u = 0;
int nr = 0;
bool m_line(line l1,line l2)
{
if((l1.B.y-l1.A.y)*(l2.B.x - l2.A.x) == (l2.B.y-l2.A.y)*(l1.B.x - l1.A.x))
return true;
return false;
}
int main()
{
in>>n;
points = new point[n+1];
for(int i=1;i<=n;i++)
{
in>>points[i].x;
in>>points[i].y;
}
in.close();
lines = new line[n*n];
for(int i=1;i<=n-1;i++)
for(int j=i+1;j<=n;j++)
{
++u;
lines[u].A.x = points[i].x;
lines[u].A.y = points[i].y;
lines[u].B.x = points[j].x;
lines[u].B.y = points[j].y;
}
for(int i=1;i<u;i++)
for(int j=i+1;j<=u;j++)
if(m_line(lines[i],lines[j]))
{
nr++;
}
out<<nr<<'\n';
out.close();
delete[] points;
delete[] lines;
return 0;
}