Cod sursa(job #571008)

Utilizator alexamiu2008Miu Alexandra alexamiu2008 Data 3 aprilie 2011 21:07:26
Problema Trapez Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<stdio.h>
FILE*fin,*fout;
struct pante{
int x,y;
}v[1001];
int i,j,n,nrt,a[1001],b[1001],nr,px,py;
int main(){
fin=fopen("trapez.in","r");
fout=fopen("trapez.out","w");
fscanf(fin,"%d",&n);
for(i=1;i<=n;i++){
fscanf(fin,"%d %d",&a[i],&b[i]);
}
for(i=1;i<=n;i++){
for(j=i+1;j<=n;j++){
if(b[i]==b[j]){px++;}
if(a[i]==a[j]){py++;}
else   {
nr++;
v[nr].x=b[j]-b[i];
v[nr].y=a[j]-a[i];
}
}


}
		  nrt=0;
for(i=1;i<=n;i++){
for(j=i+1;j<=n;j++){
if(v[i].x*v[j].y==v[i].y*v[j].x){nrt++;}
    }
}
nrt=nrt+px*(px-1)/2;
nrt=nrt+py*(py-1)/2;
fprintf(fout,"%d",nrt);
return 0;
}