美文网首页
Construct the rectangle

Construct the rectangle

作者: VanessaC | 来源:发表于2017-07-26 23:07 被阅读0次

给出长方形的面积area,求相差较小的长和宽

class Solution {public:    vectorconstructRectangle(int area) {

for(int mid = sqrt(area);mid>0;--mid)

if(area%mid == 0)

return {area/mid,mid};

}

};

其中,{area/mid,mid}是C++中数组的写法

相关文章

网友评论

      本文标题:Construct the rectangle

      本文链接:https://www.haomeiwen.com/subject/kurakxtx.html