cosmin Administrator

Data inscrierii: 30/Apr/2010 Mesaje: 12
|
Trimis: 30/04/2010 09:24 Titlul subiectului: Placa |
|
|
#include<iostream>
using namespace std;
int l,h,i,n,xf,yf,lf,hf,xv[10],yv[10];
int dimp(int x,int y,int l,int h, int& xf, int& yf, int& lf, int& hf, int xv[10], int yv[10])
{
int gasit=0;
int i=1;
while(i<=n && !gasit)
if(xv[i]>x && xv[i]<l && yv[i]>y && yv[i]<y+h)
gasit=1;
else i++;
if(gasit)
{
dimp(x,y,xv[i]-x,h,xf,yf,lf,hf,xv,yv);
dimp(xv[i],y,l+x-xv[i],h,xf,yf,lf,hf,xv,yv);
dimp(x,y,l,yv[i]-y,xf,yf,lf,hf,xv,yv);
dimp(x,yv[i],l,h+y-yv[i],xf,yf,lf,hf,xv,yv);
}
else
if(l*h>lf*hf)
{
xf=x;
yf=y;
lf=1;
hf=h;
}
}
int main()
{
int i;
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
{
cout<<"x["<<i<<"]=";cin>>xv[i];
cout<<"y["<<i<<"]=";cin>>yv[i];
}
cout<<"l=";cin>>l;
cout<<"h=";cin>>h;
dimp(0,0,l,h,xf,yf,lf,hf,xv,yv);
cout<<"x="<<xf<<" y="<<yf<<" l="<<lf<<" h="<<hf;
} |
|