[不是问题]编写打印数字的程序

编程入门 行业动态 更新时间:2024-10-28 07:32:36
本文介绍了[不是问题]编写打印数字的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

编写一个程序,打印从1到100的数字。但是对于三个打印的Fizz而不是数字的倍数和五个打印Buzz的倍数。对于三和五的倍数的数字打印FizzBu​​zz。

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

推荐答案

我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。 亲自尝试,你可能会发现它不是你想的很难! We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is not as difficult as you think!

这是算法 循环1到100 开始 1.将数字除以3.如果结果为0则表示为3的倍数,打印Fizz 2.将数字除以5.如果结果为0则表示为5的倍数,打印Buzz 3.如果步骤1和步骤2结果为0,则打印FizzBu​​zz 4.如果步骤1或步骤2的结果不等于0,则只需打印该号码。 结束 Here's the algorithm Loop through 1 to 100 Begin 1. Divide the number by 3. If the result is 0 then it is said to be a multiple of 3 , Print "Fizz" 2. Divide the number by 5. If the result is 0 then it is said to be a multiple of 5 , Print "Buzz" 3. If Step 1 and Step 2 Results into 0 then print "FizzBuzz" 4. If Step 1 or Step 2 result is not equal to 0 then just print that number. End

更多推荐

[不是问题]编写打印数字的程序

本文发布于:2023-08-07 07:01:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1317634.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数字   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!