Pagini recente » Cod sursa (job #1552605) | Cod sursa (job #1374032) | Cod sursa (job #579541) | Cod sursa (job #1038377) | Cod sursa (job #26487)
Cod sursa(job #26487)
#include<stdio.h>
struct nod
{int x,y;
nod *urm;}*p,*u,*c,*q,*s;
FILE *f=fopen("ograzi.in","r");
FILE *g=fopen("ograzi.out","w");
int n,m,h,w,nr;
void citire()
{int i,a,b;
fscanf(f,"%d %d %d %d",&n,&m,&h,&w);
fscanf(f,"%d %d",&a,&b);
c=new nod; c->x=a;c->y=b;
c->urm=0;p=u=c;
for(i=2;i<=n;i++)
{fscanf(f,"%d %d",&a,&b);
c= new nod;c->x=a;c->y=b;
c->urm=NULL; u->urm=c;
u=c;}
fscanf(f,"%d %d",&a,&b);
c=new nod; c->x=a;c->y=b;c->urm=0;
q=s=c;
for(i=2;i<=m;i++)
{fscanf(f,"%d %d",&a,&b);
c=new nod; c->x=a;c->y=b;
c->urm=0;s->urm=c;s=c;}
fclose(f);
}
void cautare()
{int i,j; nod *k;
c=p;k=q;
while(c)
{while (k)
{if(k->x>=c->x && k->x<=c->x+w && k->y>=c->y && k->y<=c->y+h)
nr++;
k=k->urm;}
c=c->urm;}
}
int main()
{citire();
cautare();
fprintf(g,"%d",nr);
return 0;
}