子弹打水箱.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《子弹打水箱.docx》由会员分享,可在线阅读,更多相关《子弹打水箱.docx(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、考前须知:1 .根据学号后两位除7后的余数选择相应的题目。2 . 6月30日前将程序以邮件形式提交,邮件主题为“课程设计*。在附件中应包括以下内容:i .题目译文,解题思路,主要算法,测试数据及运行结果,文件名为 * doc。ii .源代码,文件名为*.cpp。iii .测试数据文件。3 . *为学号后四位。4 .数据的输入输出格式可以自行决定,不必按题目的要求。1第0题Z(In this example, n = 3)(d,d,d)y(x2,y2,z2)(xl,yl,zl)X(0,0,0)A cube is suspended in space. A Cartesian coordinate
2、 system is defined with its origin at one ofthe bottom corners of the cube, as shown in the figure. The cube has side dimensiond, so itsoppositecornersareatcoordinates(OzO,0)and(d,d,d),Thepositivez- directionofthecoordinate system is up with respect to gravity.if(v2!=0)考虑垂直于z轴的(n+1)个平面与子弹轨迹的相交情况。for
3、(i=0;i=0&compare(c0/d)=0&compare (cl,d)=0)(up=i+l;一般情况对受损小水箱上下位置赋值。down=i;if(compare(c2,0)=0)考虑边界情况造成的修正。up=down=l;if(compare(c2,d)=0)up=down=n;if(TF(cO,d/n)=l)破损点在棱上时,对受损小水箱前后位置赋值。(back=s(cO,d/n);front=s(c0,d/n)+l; elseback=front=s(c0,d/n);if(compare(c=0)考虑边界情况造成的修正。back=front=l;if(compare(c0,d)=0)
4、back=front=n;if(TF(cl,d/n)=l)破损点在棱上时,对受损小水箱左右位置赋值。(left=s(cl,d/n);right=s(clzd/n)+l;)7elseleft=right=s(cl,d/n);if(compare(cl,0)=0)考虑边界情况造成的修正。left=right=l;if(compare(cl,d)=0)left=right=n;sixdir00=front;sixdir0l=back;为了方便,将各方位数据放在二维数组 中。sixdirlO=left;sixdirll=right;sixdir20=up;sixdir2l=down;for(j=0;j
5、2;j+)for(k=0;k2;k+) for(m=0;mhsixdir0j-lsixdirlk-lsixdir2m-l)hsixdir0j-lsixdirlk-lsixdir2m-l=hlost;)hlost=0;for(i=0;in;i+)统计漏掉的水的总量hlostofor(j=0;jn;j+)for(k=0;kn;k+)if(piUk=l)hlost+=hijk;printf(漏掉的水的体积及其百分比为:n%.3lf, %.llf%n,hlost*pow(d/n,2),100*hlost/d/pow(n,2.0);以下程序(至主函数末尾)可显示受损小水箱的位置及其俯视图。如不需 要,可
6、以将其注释掉。printf(受损小水箱的俯视位置(矩阵元素1表示受损,0表示未受损)及子 水箱漏水占各自的比重:n);for(k=0;kn;k+)for(i=0;in;i+)for(j=0;jn;j+)if(piUk=l)8printf(%d,%d,%d)/,i+lj+l,k+l);printf(n);for(i=0;in;i+)(for(j=0;jn;j+)printf(%d ,pijk);printf( );for(j=0;jn;j+)printf(%.3lf ,hijk*n/d);printf(n);)printf(n);)intcomparefdoublex.doubley) if(f
7、abs(x-y)0)returnl;elseif(x-y0)return-1;)intTF(doublex,doubley)(if(compare(fmod(x,y),y)=011 compare(fmod(x,y),0)=0)returnl;returnO;)ints(doublex,doubley)(intshang=(int)(x/y);if(compare(fmod(x,y),y)=0)return(shang+l);if(compare(fmod(x,y),0)=0) return(shang);return(shang+l);)910The interior of the cube
8、 contains partitions with uniform spacing in each dimension, so that thecube is partitioned inton3mini-cubes of equal size. The partitions are thin and watertight, andeach mini-cube is filled with water. The total volume of water in all the minicubes isd3.A gun fires a bullet which may hit the cube.
9、 The muzzle of the gun is at the point (xLyl,z). Thepoint (x2,y2,Z1 ) is a point on the bulletspath that defines the direction of the bullet. The bulletdoes not shatter the cube, but wherever the bullet touches a side or interior partition of the cube,it makes a small hole. Bullet holes may be made
10、in the sides, edges, or corners of the interiormini-cubes. Water, influenced by gravity, may leak through these small holes. All the water thatleaks out of the large cube is collected and measured.InputTheinputdatasetconsistsofseveraltrials.Eachtrialisdescribedbyeightintegers.Thefi rstinteger isn(n
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 子弹 水箱
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内