Pagini recente » Cod sursa (job #1971302) | Cod sursa (job #2500486) | Cod sursa (job #968744) | Cod sursa (job #2393948) | Cod sursa (job #29074)
Cod sursa(job #29074)
#include<fstream.h>
typedef struct nod{long x,y; nod *urm; }TNOD;
TNOD *prim,*ultim,*nou,*p;
long k,n,x,y,w,h,m,x1,y1,st=320000,dr=-320000,jos=320000,sus=320000;
int test()
{ int ok=0;
while (p)
{
if(x1>=p->x&&x1<=p->x+w&&y1>=p->y&&y1<=p->y+h) {ok=1; break;}
p=p->urm;
}
return ok;
}
void creare()
{
}
int main()
{long i,j,nr=0;
ifstream f("ograzi.in");
f>>n>>m>>w>>h;
prim=new TNOD;
f>>x1>>y1;
prim->x=x1; prim->y=y1;
if(x1<st) st=x1;
if(x1+w>dr) dr=x1+w;
if(y1<jos) jos=y1;
if(y1+h>sus) sus=x1+h;
prim->urm=NULL;
ultim=prim;
for(i=2;i<=n;i++)
{f>>x1>>y1;; nou=new TNOD; nou->x=x1; nou->y=y1; nou->urm=NULL; ultim->urm=nou; ultim=nou;
if(x1<st) st=x1;
if(x1+w>dr) dr=x1+w;
if(y1<jos) jos=y1;
if(y1+h>sus) sus=x1+h;
}
for(i=1;i<=m;i++)
{f>>x1>>y1; p=prim;
if(x1>=st||x1<=dr||y1<=sus||y1>=jos)
if(test()) nr++;
} f.close();
ofstream g("ograzi.out");
g<<nr;
g.close();return 0;
}