《Cracking the Coding Interview》——第7章:数学和概率论——题目5

2014-03-20 02:20

题目:给定二维平面上两个正方形,用一条直线将俩方块划分成面积相等的两部分。

解法:穿过对称中心的线会将面积等分,所以连接两个中心即可。如果两个中心恰好重合,那么任意穿过这个点的直线都满足条件。

代码:

 // 7.5 Given two squares on two-dimensional plane, draw a line to cut them in two parts with equal area.
// Answer:
// Apparently the line should go through the center of the two squares.
// If their center coincide, any line that goes through this center will suffice.
int main()
{
return ;
}
上一篇:mysql数据库编码设置成utf-8,避免出现乱码


下一篇:c++实现冒泡排序