const int maxlength=21;
const double minborder=0.3;
const double spc=0.157;
double boradLength;
double boradWidth;
int main(int argc, char *argv[])
{
int i=0, j=0, y=0, z=0;
double tempLength, tempWidth, tempwaste;
double bl, bw;
double minWaste, mlength, mwidth;
int lx=0, wx=0;
double sizex[]={48,36,40,42};
minWaste = 1000;
cin >> boradLength;
cin >> boradWidth;
printf("Waste area Panel size Base size Pattern Border(L) Border(W) No.of Pcs\n");
y = 0;
for (i=1;(((i*boradLength)+(i-1)*spc)+ minborder*2) < maxlength;i++)
{
tempLength = sizex[y] / floor(sizex[y]/(((i*boradLength)+(i-1)*spc)+ minborder*2));
for (z=1;z<4;z++)
for (j=1;(((j*boradWidth)+(j-1)*spc)+minborder*2) < maxlength;j++)
{
tempWidth = sizex[z] / floor(sizex[z]/(((j*boradWidth)+(j-1)*spc)+minborder*2));
if ((y != z) && ((y==0)||(z==0)))
{
tempwaste=((tempLength*tempWidth)-(boradWidth*boradLength*i*j))/(i*j);
if ((tempwaste <= minWaste) && (tempwaste > 0))
{
minWaste = tempwaste;
mlength = sizex[y];
mwidth = sizex[z];
bl = tempLength;
bw = tempWidth;
lx = i;
wx = j;
printf("%7.3f %6.3fx%6.3f %2.0fx%2.0f %2dx%-2d %6.3f %6.3f %3.0f\n", tempwaste,
bl, bw, mlength, mwidth, lx, wx,
(bl-lx*boradLength-(lx-1)*spc)/2,
(bw-wx*boradWidth-(wx-1)*spc)/2,
mlength/bl*lx*mwidth/bw*wx);
}
}
}
}
y = 0;
for (i=1;(((i*boradWidth)+(i-1)*spc)+ minborder*2) < maxlength;i++)
{
tempWidth = sizex[y] / floor(sizex[y]/(((i*boradWidth)+(i-1)*spc)+ minborder*2));
for (z=1;z<4;z++)
for (j=1;(((j*boradLength)+(j-1)*spc)+minborder*2) < maxlength;j++)
{
tempLength = sizex[z] / floor(sizex[z]/(((j*boradLength)+(j-1)*spc)+minborder*2));
if ((y != z) && ((y==0)||(z==0)))
{
tempwaste=((tempLength*tempWidth)-(boradWidth*boradLength*i*j))/(i*j);
if ((tempwaste <= minWaste) && (tempwaste > 0))
{
minWaste = tempwaste;
mlength = sizex[z];
mwidth = sizex[y];
bl = tempLength;
bw = tempWidth;
lx = j;
wx = i;
printf("%7.3f %6.3fx%6.3f %2.0fx%2.0f %2dx%-2d %6.3f %6.3f %3.0f\n", tempwaste,
bl, bw, mlength, mwidth, lx, wx,
(bl-lx*boradLength-(lx-1)*spc)/2,
(bw-wx*boradWidth-(wx-1)*spc)/2,
mlength/bl*lx*mwidth/bw*wx);
}
}
}
}
return 0;
}
--
※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: as3po191.ty.ficnet.net.tw