class Solution {
public:
/**
* param n: As description.
* return: A list of strings.
*/
vector<string> fizzBuzz(int n) {
vector<string> results;
for (int i = ; i <= n; i++) {
if (i % == ) {
results.push_back("fizz buzz");
} else if (i % == ) {
results.push_back("buzz");
} else if (i % == ) {
results.push_back("fizz");
} else {
results.push_back(to_string(i));
}
}
return results;
}
};

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. LintCode (9)Fizz Buzz

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

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

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

  7. Swift完成fizz buzz test

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

  8. [Swift]LeetCode412. Fizz Buzz

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

  9. Fizz Buzz 面试题

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

随机推荐

  1. [LeetCode] Minimum Size Subarray Sum 解题思路

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  2. Android中实现控件圆角边框

    首先,在drawable文件夹下新建一个xml文件: <?xml version="1.0" encoding="utf-8"?> <shap ...

  3. Spring技术内幕——深入解析Spring架构与设计原理(一)IOC实现原理

    IOC的基础 下面我们从IOC/AOP开始,它们是Spring平台实现的核心部分:虽然,我们一开始大多只是在这个层面上,做一些配置和外部特性的使用工作,但对这两个核心模块工作原理和运作机制的理解,对深 ...

  4. View,viewgroup,viewstub总结

    :first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; m ...

  5. 如何在ubuntu下使用stage3d的硬件加速

    最近想尝试一下心动的新游戏深渊,但是由于公司的电脑是ubuntu的,只要进游戏就提示说没有stage3d的硬件加速,于是google了一下,发现这么一篇文章 http://phoronix.com/f ...

  6. 转:Myeclipse连接MySQL数据库经验分享

    要使除 JDBC ODBC Bridge 之外的 Driver 生效,需要手动配置. 首先获得 MySQL Connector / J 的 jar : http://dev.mysql.com/dow ...

  7. PCAP 文件内容解析命令

    针对网络接口.端口和协议的数据包截取.假定你要截取网络接口eth1,端口号6881的tcp数据包.数据文件保存为test.pcap. tcpdump -w test.pcap -i eth1 tcp ...

  8. Java获取当前目录方法整理

    假设项目路径是E:\Workspaces\MyProgram\FilePath 1.使用System.getProperty("user.dir"),获得项目的根路径,返回Stri ...

  9. 给EditText的drawableRight属性的图片设置点击事件 分类: 学习笔记 android 2015-07-06 13:20 134人阅读 评论(0) 收藏

    这个方法是通用的,不仅仅适用于EditText,也适用于TextView.AutoCompleteTextView等控件. Google官方API并没有给出一个直接的方法用来设置右边图片的点击事件,所 ...

  10. 在KALI LINUX中安装JAVA JDK

    1. 下载最新的JAVA JDK jdk-8u91-linux-x64 2. 解压缩文件并移动至/opt tar -xzvf jdk-8u91-linux-x64.tar.gz mv jdk1.8.0 ...