【发布时间】:2013-06-03 23:36:20
【问题描述】:
我有n 元素作为输入和一个函数make_grid(n),它将计算包含这些元素的网格的尺寸。假设n = 12,那么函数必须计算出宽度为4,高度为3,而不是1和12左右。同样,n = 24 应该返回 6 和 4。
我尝试使用ceil(sqrt(n)) 来获得一维,但根本不是一般情况,并且使用情况(偶数,sqrt(n) == ceil(sqrt(n)))没有奏效。
编辑: Finding the optimum column and row size for a table with n elements and a given range for its proportion 我已经看到了这个问题,但编码让我想到了 n = 24 维 5 和 5。 有什么帮助吗?
【问题讨论】: