首页 > 其他 > 详细

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

时间:2014-03-20 21:22:27      阅读:487      评论:0      收藏:0      [点我收藏+]

2014-03-20 02:20

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

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

代码:

bubuko.com,布布扣
1 // 7.5 Given two squares on two-dimensional plane, draw a line to cut them in two parts with equal area.
2 // Answer:
3 //    Apparently the line should go through the center of the two squares.
4 //    If their center coincide, any line that goes through this center will suffice.
5 int main()
6 {
7     return 0;
8 }
bubuko.com,布布扣

《Cracking the Coding Interview》——第7章:数学和概率论——题目5,布布扣,bubuko.com

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

原文:http://www.cnblogs.com/zhuli19901106/p/3612773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!