Cod sursa(job #2290044)

Utilizator IoanaDraganescuIoana Draganescu IoanaDraganescu Data 25 noiembrie 2018 18:14:49
Problema Trapez Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

ifstream fin("trapez.in");
ofstream fout("trapez.out");

struct punct
{
    int x, y;
}v[100005], p[1005];

int main()
{
    int n, k = 0;
    fin >> n;
    for (int i = 1; i <= n; i++)
        fin >> p[i].x >> p[i].y;
    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++)
        {
            k++;
            v[k].x = p[j].x - p[i].x;
            v[k].y = p[j].y - p[i].y;
        }
    int nr = 0;
    for (int i = 1; i < k; i++)
        for (int j = i + 1; j <= k; j++)
            if (v[i].x * v[j].y == v[i].y * v[j].x)
                nr++;
    fout << nr << '\n';
    return 0;
}