我是靠谱客的博主 活泼猫咪,这篇文章主要介绍Write a program that prints the numbers from 1 to 100,but for multiples of three print “Fizz” inste,现在分享给大家,希望可以做个参考。

1、问题

/*

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“;

*/


2、算法

void foo()
{
        int m = 100 ;

        for(int i = 0; i <= m; i++)
        {
                if (i%(3*5) == 0)
                {
                        printf("FizzBuzz") ;
                }else if(i%3 == 0)
                {
                        printf("Fizz") ;
                }else if (i%5 == 0)
                {
                        printf("Buzz") ;
                }else
                {
                        printf("%d", i) ;
                }
        }
}

最后

以上就是活泼猫咪最近收集整理的关于Write a program that prints the numbers from 1 to 100,but for multiples of three print “Fizz” inste的全部内容,更多相关Write内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(120)

评论列表共有 0 条评论

立即
投稿
返回
顶部