有关COMP1405的Assignment1的问题!

Simpson@@@

新手上路
注册
2005-06-21
消息
156
荣誉分数
0
声望点数
0
哪位高人指点一下:用3个int表示一个盒子的体积,1个float表示一个球的半径,写code要能计算出这个盒子能装下多少个球?

我写了改,改了又写,但运行时总是出错,谁能指点一下,谢谢!
 
将三个int分别变成float除以球的直径,得出的结果变成int 乘起来就是答案。
 
this is a very difficult question.

If you just divide it, it won't be the correct answer. since this filing is a ball.
There are gaps between balls, if you just divided the volumn of the cube, by the volumn of the ball. Your answer will include some balls that are *melted* and fills in all the gap between balls.

So, you should think about that problem.

To solve yours, to convert all INTs to FLOAT and do the calculation.
 
老师肯定给算法的。1年纪很少要自己想算法的课
 
后退
顶部