[不是问题]编写打印数字的程序 [英] [Not a question] Write a program that prints the numbers

查看:186
本文介绍了[不是问题]编写打印数字的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个程序,打印从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


这篇关于[不是问题]编写打印数字的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆