Cod sursa(job #1380571)

Utilizator ArambasaVlad Arambasa Arambasa Data 8 martie 2015 08:34:21
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <fstream>
//#include <iostream>
#include <algorithm>
#define NMax 1005
#define MMax 5000
using namespace std;
ifstream in ("trapez.in");
ofstream out ("trapez.out");
struct Punct
{
    int x,y;
}punct[NMax];
int m [MMax];
int N;
int main()
{
    in>>N;
    for (int i=1;i<=N;i++)
    {
        in>>punct[i].x>>punct[i].y;
    }
    int M=0;
    for (int i=1;i<=N-1;i++)
        for (int j=i+1;j<=N;j++)
    {
        M++;
        if(punct[i].y-punct[j].y)
        m[M]=(punct[i].x-punct[j].x)/(punct[i].y-punct[j].y);
        else
        m[M]=(punct[i].y-punct[j].y)/(punct[i].x-punct[j].x);

    }
    int contor=0;
    sort(m+1,m+M+1);
    for (int i=1;i<=M-1;i++)
    {
            if (m[i]==m[i+1])
                contor++;
    }
    out<<contor;
    return 0;
}