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 ...
随机推荐
- awk 复习
awk 的再次学习!!!! awk 的一般模式 awk '{parttern + action }' {filename} , 提取/etc/passwd 的用户 awk -F ":&quo ...
- hive高级数据类型
hive的高级数据类型主要包括:数组类型.map类型.结构体类型.集合类型,以下将分别详细介绍. 1)数组类型 array_type:array<data_type> -- 建表语句 cr ...
- PHP 利用CURL(HTTP)实现服务器上传文件至另一服务器
// 上传端 /** * 向目标地址推送xls文件 * @Date 2019/4/29 */ public function putXls() { // 目标接口 $url = "http: ...
- flink with rabbitmq,sink source mysql redis es
flink-dockerhttps://github.com/melentye/flink-docker https://shekharsingh.com/blog/2016/11/12/apache ...
- LeetCode 606 Construct String from Binary Tree 解题报告
题目要求 You need to construct a string consists of parenthesis and integers from a binary tree with the ...
- 缓存机制 ehcache、redis
本文主要记录ehcache和redis实现缓存(redis版本号:5.0.3) 一.ehcache 1.ehcache:用来管理Java中缓存的轻量级工具,其核心通过CacheManager使用,一般 ...
- ESP8266 RTOS SDK(IDF)编译环境搭建
前提条件 按照https://www.cnblogs.com/ansersion/p/10458171.html的步骤搭建非IDF环境 下载 https://github.com/espressif/ ...
- python类之魔法方法
python类之魔法方法: class A(object): def __init__(self,x): self.x = x def __neg__(self): print('-v') def _ ...
- c# 设置开机启动
private static RegistryKey _rlocal = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Wi ...
- 初识STL vector
写这个主要是当作笔记来写的,配上自己的理解加上一些测试示例; 上代码: #include<iostream>#include<cstring>#include<vecto ...