Fizz Buzz 面试题
在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 面试题的更多相关文章
- [LeetCode] Fizz Buzz 嘶嘶嗡嗡
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
- Lintcode 9.Fizz Buzz 问题
------------------------ AC代码: class Solution { /** * param n: As description. * return: A list of s ...
- LeetCode 412. Fizz Buzz
Problem: Write a program that outputs the string representation of numbers from 1 to n. But for mult ...
- LeetCode Fizz Buzz
原题链接在这里:https://leetcode.com/problems/fizz-buzz/ 题目: Write a program that outputs the string represe ...
- Fizz Buzz
class Solution { public: /** * param n: As description. * return: A list of strings. */ vector<st ...
- LintCode (9)Fizz Buzz
下面是AC代码,C++风格: class Solution { public: vector<string> fizzBuzz(int N) { vector<string> ...
- [重构到模式-Chain of Responsibility Pattern]把Fizz Buzz招式重构到责任链模式
写一段程序从1打印到100,但是遇到3的倍数时打印Fizz,遇到5的倍数时打印Buzz,遇到即是3的倍数同时也是5的倍数时打印FizzBuzz.例如: 1 2 Fizz 4 Buzz Fizz 7 8 ...
- Swift完成fizz buzz test
看到一篇文章上说,很多貌似看过很多本编程书的童鞋连简单的fizz buzz测试都完不成. 不知道fizz buzz test为何物的,建议自行搜之. 测试要求是,编写满足以下条件的代码: Write ...
- [Swift]LeetCode412. Fizz Buzz
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
随机推荐
- linux下fcitx的安装与配置
首先安装fcitx pacman -S fcitx-im fcitx-config fcitx-cloudpinyin 之后进行配置 nano ~/.xprofile 写入 export XIM=fc ...
- esyui datagrid 水平方向下方出来滚动条的原因是因为使用了同一列名
esyui datagrid 水平方向下方出来滚动条的原因是因为使用了同一列名
- HC32F003与STM8S003资源对比,只是对比,大家评论~!
枯藤老树昏鸦小桥流水人家 古道西风瘦马夕阳西下断肠人在天涯 18年悄然过去!19年向我们走来,蓦然回首过 ...
- c++函数strapy
头文件:#include <string.h> 定义函数:char *strcpy(char *dest, const char *src); 函数说明:strcpy()会将参数src 字 ...
- Js中Map对象的使用
Js中Map对象的使用 1.定义 键/值对的集合. 2.语法 mapObj = new Map() 3.备注 集合中的键和值可以是任何类型.如果使用现有密钥向集合添加值,则新值会替换旧值. 4.属性 ...
- day26:静态方法,类方法和反射
1,包内部不要去尝试应用使用相对导入,一定不会成功的,他不支持这个机制,包内导入时一定要用绝对导入 2,复习接口类,抽象类,Python中没有接口类,有抽象类,抽象类是通过abc模块中的metacla ...
- python特定时间发送消息到微信公众号
#!/usr/bin/env python# -*- coding: utf-8 -*-# __author__ = 'James'# 导入模块from wxpy import *import tim ...
- 从github上下载一个项目的子目录
https://github.com/pbojinov/developer.chrome.com/tree/master/extensions/examples/extensions/proxy_co ...
- Linux - ansible 安装
# 安装依赖 yum install rpm-build python2-devel sshpass PyYAML python-jinja2 python-paramiko python-six p ...
- CSS盒子模型 box-sizing 用法
盒子模型 box-sizing 属性 语法:box-sizing :content-box || border-box || inherit 属性值: content-box 为(w3c标准盒子模型 ...