Cod sursa(job #1649681)

Utilizator mirunazMiruna Zavelca mirunaz Data 11 martie 2016 14:35:30
Problema Trapez Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include<cstdio>
using namespace std;
int n,i,j,k,h,x,xx,y,yy,ct=0;
struct sheldon{int l,c;};
sheldon v[1001];
FILE *in, *out;
int main ()
{
    in=fopen("trapez.in","r");
    out=fopen("trapez.out","w");
    fscanf(in,"%d",&n);
    for(i=1;i<=n;i++)
        fscanf(in,"%d %d",&v[i].l,&v[i].c);
    for(i=1;i<n;i++)
        for(j=i+1;j<=n;j++)
        {
            x=v[j].l-v[i].l;
            y=v[j].c-v[i].c;
            for(h=i+1;h<n;h++)
                if(h!=j)
                   for(k=h+1;k<=n;k++)
                        if(k!=j)
                        {
                            xx=v[k].l-v[h].l;
                            yy=v[k].c-v[h].c;
                            if(x*yy == y*xx)
                                ct++;
                        }
        }
    fprintf(out,"%d\n",ct);
    return 0;
}