Pagini recente » Borderou de evaluare (job #1034752) | Cod sursa (job #1988119) | Cod sursa (job #1959011) | Cod sursa (job #2805515) | Cod sursa (job #1141135)
#include <fstream>
#include <cstdlib>
using namespace std;
ifstream is("trapez.in");
ofstream os("trapez.out");
struct punct{
int x, y;
} p[1001];
int n;
int answ;
bool PARALELE(punct a1, punct a2, punct b1, punct b2);
int main()
{
is >> n;
for ( int i = 1; i <= n; ++i )
is >> p[i].x >> p[i].y;
for ( int i1 = 1; i1 <= n - 1; ++i1 )
for ( int j1 = i1 + 1; j1 <= n; ++j1 )
for ( int i2 = 1; i2 <= n - 1; ++i2 )
for ( int j2 = i2 + 1; j2 <= n; ++j2 )
{
if ( i1 == j1 || i1 == i2 || i1 == j2 || j1 == i2 || j1 == j2 || i1 == i2 )
continue;
if ( PARALELE(p[i1], p[j1], p[i2], p[j2]) )
{
++answ;
//os << i1 << " " << j1 << " " << i2 << " " << j2 << "\n";
}
}
os << answ / 2;
is.close();
os.close();
return 0;
}
bool PARALELE(punct a1, punct a2, punct b1, punct b2)
{
if ( a1.x == a2.x || b1.x == b2.x )
{
if ( a1.x == a2.x && b1.x == b2.x )
return true;
return false;
}
if ( (a1.x - a2.x) * (b1.y - b2.y) == (b1.x - b2.x) * (a1.y - a2.y) )
return true;
return false;
}