Pagini recente » Cod sursa (job #1647028) | Cod sursa (job #2669231) | Cod sursa (job #1019367) | Cod sursa (job #1495271) | Cod sursa (job #1122722)
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
#define MAX 1100
map < float , int > harta;
pair<int, int> a[MAX];
int main()
{
int n, i, j, x, y, l=0;
fin>>n;
for(i=1;i<=n;i++)
{
fin>>a[i].first>>a[i].second;
}
for(i=1;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
x=a[i].first-a[j].first;
y=a[i].second-a[j].second;
if(x==0)
l++;
else
harta[(float)y/x]++;
}
}
int s=l*(l-1)/2;
for(map<float, int>::iterator it=harta.begin();it!=harta.end();it++)
{
l=(*it).second;
s+=(l*(l-1)/2);
}
fout<<s;
}