在CSDN上看到一篇文章《软件工程师如何笑着活下去》,本来是想看对这个行业的一些评价和信息,不曾检索到关于Fizz Buzz的面试题,上网搜了一下,顿感兴趣。留下此文,以表回忆。

java语言 小白基础写法:
 public class FizzBuzz {
    public static void main(String[] args) {
        for (int i = 1; i <= 100; i++) {                                                //for循环遍历1-100的数
            if (i % 3 ==0 & i%5 == 0) {                                             //循环出的数字i%3和%5看是否相等,相当输出原有数字+FizzBute。
                System.out.println(i+" "+"FizzBute");
            }else if(i%3==0) {                                                            //循环出的数分别%3,相当输出 i+Fizz.
                System.out.println(i+" "+"Fizz");
                
            }else if(i%5==0) {                                                             //循环出的数分别%5,相当输出 i+Bute.
                System.out.println(i+" "+"Bute");
            }
            else if(i%10==3) {              
                System.out.println(i+" f");                                             //个位数不包含,十位数包含3的输出原数字 +f
            }
            else {
                System.out.println(i);                                                //输出原有循环的数字以便容易辨认。
            }
        }
    }
}

Fizz Buzz 面试题的更多相关文章

  1. [LeetCode] Fizz Buzz 嘶嘶嗡嗡

    Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...

  2. Lintcode 9.Fizz Buzz 问题

    ------------------------ AC代码: class Solution { /** * param n: As description. * return: A list of s ...

  3. LeetCode 412. Fizz Buzz

    Problem: Write a program that outputs the string representation of numbers from 1 to n. But for mult ...

  4. LeetCode Fizz Buzz

    原题链接在这里:https://leetcode.com/problems/fizz-buzz/ 题目: Write a program that outputs the string represe ...

  5. Fizz Buzz

    class Solution { public: /** * param n: As description. * return: A list of strings. */ vector<st ...

  6. LintCode (9)Fizz Buzz

    下面是AC代码,C++风格: class Solution { public: vector<string> fizzBuzz(int N) { vector<string> ...

  7. [重构到模式-Chain of Responsibility Pattern]把Fizz Buzz招式重构到责任链模式

    写一段程序从1打印到100,但是遇到3的倍数时打印Fizz,遇到5的倍数时打印Buzz,遇到即是3的倍数同时也是5的倍数时打印FizzBuzz.例如: 1 2 Fizz 4 Buzz Fizz 7 8 ...

  8. Swift完成fizz buzz test

    看到一篇文章上说,很多貌似看过很多本编程书的童鞋连简单的fizz buzz测试都完不成. 不知道fizz buzz test为何物的,建议自行搜之. 测试要求是,编写满足以下条件的代码: Write ...

  9. [Swift]LeetCode412. Fizz Buzz

    Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...

随机推荐

  1. lamdba表达式

    lambda表达式是一个可传递的代码块,可以在以后执行一次或多次. lambda表达式的语法: 1. 参数 -> 表达式(无需指定返回类型) (String first, String seco ...

  2. 将win7 设置为 NTP服务器

    1. 修改注册表项 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer Enabl ...

  3. Ultimate Guide to WhatsApp for Business 2019

    By Iaroslav Kudritskiy (Source: https://rocketbots.io/blog/the-ultimate-guide-to-whatsapp-business-a ...

  4. python中删除list元素的方法del()、pop()和remove()

    del():根据下标进行删除 In [1]: a = [1, 2, 3, 4, 5] In [2]: del a[0] In [3]: a Out[4]: [2, 3, 4, 5] pop(): 删除 ...

  5. LeetCode 538 Convert BST to Greater Tree 解题报告

    题目要求 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the origi ...

  6. 如何彻底禁止win10易升更新(转)

    原文:https://blog.csdn.net/qq_33075489/article/details/79755896 add by zhj: 第二步是我自己加的 Win10版本:家庭中文版64位 ...

  7. div盒子水平居垂直中的几种方法

      div盒子水平居垂直中的几种方法<!DOCTYPE html><html>    <head>        <mete charset="ut ...

  8. python中闭包的理解

    闭包的三个条件: 1.函数(外函数)中定义了内函数:2.内函数使用了外函数的非全局变量:3.外函数最终返回的是内函数的引用. 简单闭包事例: #outerfunc为外函数 def outerfunc( ...

  9. c# thread数线程的创建

    1. 1 2 3 4 5 6 Thread thread = new Thread(new ThreadStart(getpic)); thread.Start(); private void sho ...

  10. MySQL 8.0 InnoDB新特性

    MySQL 8.0 InnoDB新特性 1.数据字典全部采用InnoDB引擎存储,支持DDL原子性.crash safe,metadata管理更完善 2.快速在线加新列(腾讯互娱DBA团队贡献) 3. ...