Pagini recente » Cod sursa (job #1002798) | Cod sursa (job #1681700) | Cod sursa (job #243656) | Cod sursa (job #2032543) | Cod sursa (job #2276569)
#include <fstream>
using namespace std;
typedef struct
{
int x;
int y;
} point;
float findM(point a, point b)
{
return (float) (b.y - a.y) / (b.x - a.x);
}
int main()
{
int noPoints;
point p[1000];
float m1;
float m2;
int noResults = 0;
ifstream fin("trapez.in");
fin >> noPoints;
for(int i = 0; i < noPoints; i++)
{
fin >> p[i].x;
fin >> p[i].y;
}
fin.close();
for(int i = 0; i < noPoints; i++)
{
for(int j = i + 1; j < noPoints; j++)
{
//if(i == j) continue;
m1 = findM(p[i], p[j]);
for(int k = 0; k < noPoints; k++)
{
for(int l = k + 1; l < noPoints; l++)
{
//if(k == l) continue;
if( (k == i && l == j) || (k == j && l == i)) continue;
m2 = findM(p[k], p[l]);
if(m1 == m2) noResults++;
}
}
}
}
//noResults = (noResults - noPoints)/2;
ofstream fout("trapez.out");
fout << noResults / 2;
fout.close();
return 0;
}