Pagini recente » Cod sursa (job #1488025) | Cod sursa (job #1836072) | Cod sursa (job #2357894) | Istoria paginii runda/punetiosullatreaba | Cod sursa (job #2550808)
#include <bits/stdc++.h>
#define NMAX 1009
#define INF 99999
using namespace std;
ifstream fin("trapez.in");
ofstream fout("trapez.out");
struct tip{double x; double y;};
struct tip1{double m; double lg;};
map<double, int>H;
map<tip1, int>H1;
map<double, int>::iterator it;
tip a[NMAX];
int n;
double m;
int i,j;
int main()
{fin>>n;
for(i=1;i<=n;i++)
fin>>a[i].x>>a[i].y;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
if(a[i].x==a[j].x)
{
H[INF]++;
}
else
{
m= (a[j].y-a[i].y)/(a[j].x-a[i].x);
H[m]++;
}
}
int sum=0;
for(it=H.begin();it!=H.end();it++)
sum+= (*it).second * ( (*it).second -1)/2;
fout<<sum;
return 0;
}