我有N个方格.我有一个矩形框.我希望所有的方块都放在盒子里.我希望方块尽可能大.
如何计算方块的最大尺寸,使它们都适合方框?
这是缩略图库中的缩略图.
int function thumbnailSize(
iItems, // The number of items to fit.
iWidth, // The width of the container.
iHeight, // The height of the container.
iMin // The smallest an item can be.
)
{
// if there are no items we don't care how big they are!
if (iItems = 0) return 0;
// Max size is whichever dimension is smaller, height or width.
iDimension = (iWidth min iHeight);
// Add .49 so that we always …Run Code Online (Sandbox Code Playgroud)