分享
分享赚钱 收藏 举报 版权申诉 / 9

类型C语言编程学习课件 (26).pdf

  • 上传人:职教中国
  • 文档编号:13895291
  • 上传时间:2022-11-06
  • 格式:PDF
  • 页数:9
  • 大小:1.23MB
  • 配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    C语言编程学习课件 (26).pdf
    资源描述:

    1、Programming In C Once, Einstein gave his friend such a mathematical problem: There is a long ladder, if each step spans 2 ladders, 1 ladder is left; Each step spans 3 ladders, with 2 ladders remaining; Each step spans 5 ladders, with 4 ladders remaining; Each step spans 6 ladders, with 5 ladders rem

    2、aining. Only when each step spans 7 ladders, it is exactly the end, and there is no one left. How many steps does the ladder have? Question 1: Einstein steps. Code #includestdio.h void main() int i; for(i=1 ; ; i+) if(i%2=1&i%3=2&i%5=4&i%6=5&i%7=0) break; printf(至少有 %d级台阶 n,i); Question 2: One hundr

    3、ed yuan buy one hundred chickens. Given that rooster is worth 5 yuan each, hen is 3 yuan each while 3 chicks are 1 yuan, if you want to buy 100 chickens with 100 yuan, then how many roosters, hens and chicks to buy? Analysis(Exhaustive method): Set the number of roosters, hens, and chicks as x, y, a

    4、nd z Given a total of 100 yuan to buy 100 chickens Value range of x、 y、 z x: y: z: 0-20 033 0100 x y z 100 5x3y z/3100 int x,y,z,j=0; printf(Following are possible plans :n); for(x=0;x=20;x+) for(y=0;y=33;y+) z=100-x-y; if(z%3=0&5*x+3*y+z/3=100) printf(%2d:cock=%2d hen=%2d chicken=%2dn,+j,x,y,z); Co

    5、de Exhaustive method/Enumeration When using the programming method, we need to determine the general scope of the answer according to some conditions of the question, and we need to verify all possible situations one by one within this scope. If a certain situation is verified to meet all the condit

    6、ions of the question, it is a solution to the problem. If it cannot meet all the conditions of the problem after verification, then the problem has no solution. Question 3: Fibonacci sequence. Fibonacci sequence The first and second Numbers are 1, 1 From the third number, you take the sum of the fir

    7、st two 1 1 2 3 5 8 13 21 34 . Background : This is an interesting classical mathematics question.If a pair of little rabbits can give birth to a new pair of rabbits every month, and each pair of new rabbits will give birth to another pair of new rabbits in the third month after birth, assuming that

    8、no death occurs, how many pairs of rabbits can be bred in a year? 1 n 2 f n f n 1 f n 2 n 2 1 n 1 1 n 2 n 1 f n 2 n 2 Iterative method #include int main() long f1,f2,fn; int i; f1 = f2 = 1; printf(%ldt%ldt,f1,f2); /求余下的 Fibonacci数 return 0; for(i=3; i=40; i+) fn = f1 + f2; printf(%ldt,fn); if(i % 5=0) printf(n); f1 = f2; f2 = fn; f n 1 n 1 f i fn f1 f2 3 4 5 2 3 5 1 1 2 3 1 2 3 5 5 8 6 7 8 . Programming In C

    展开阅读全文
    提示  道客多多所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:C语言编程学习课件 (26).pdf
    链接地址:https://www.docduoduo.com/p-13895291.html
    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    道客多多用户QQ群:832276834  微博官方号:道客多多官方   知乎号:道客多多

    Copyright© 2025 道客多多 docduoduo.com 网站版权所有世界地图

    经营许可证编号:粤ICP备2021046453号    营业执照商标

    1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png



    收起
    展开