C++

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

LintCode: Fizz Buzz的更多相关文章

  1. Lintcode 9.Fizz Buzz 问题

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

  2. LintCode (9)Fizz Buzz

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

  3. [容易]Fizz Buzz 问题

    题目来源:http://www.lintcode.com/zh-cn/problem/fizz-buzz/

  4. [LeetCode] Fizz Buzz 嘶嘶嗡嗡

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

  5. LeetCode 412. Fizz Buzz

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

  6. LeetCode Fizz Buzz

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

  7. Fizz Buzz

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

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

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

  9. Swift完成fizz buzz test

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

随机推荐

  1. C#编程(三十八)----------运算符

    原文链接: http://blog.csdn.net/shanyongxu/article/details/46877353 运算符 类别 运算符 算术运算符 + - * / 逻辑运算符 &  ...

  2. 架构:Eventually Consistent - Revisited

    原文地址:http://i.cnblogs.com/EditPosts.aspx?opt=1. I wrote a first version of this posting on consisten ...

  3. ibatis.net:第五天,QueryForObject

    xml <statement id="LoadOrder" parameterClass="int" resultClass="Order&qu ...

  4. linux syslog详解 转

    分三部分 一.syslog协议介绍 二.syslog函数 三.linux syslog配置   一.syslog协议介绍 1.介绍 在Unix类操作系统上,syslog广泛应用于系统日志.syslog ...

  5. spring 深入reading

    http://wenku.baidu.com/view/8db141624a7302768e9939b3.html http://docs.spring.io/spring/docs/4.2.1.BU ...

  6. [Web 前端] 流行的JavaScript库 ——jQuery

    cp : https://www.cnblogs.com/zhoushihui/p/5141767.html   1.为了简化 JavaScript 的开发, 一些 JavsScript 库诞生了. ...

  7. Java 集合细节(二):asList 的缺陷

    在实际开发过程中我们经常使用 asList 讲数组转换为 List,这个方法使用起来非常方便,但是 asList 方法存在几个缺陷: 一.避免使用基本数据类型数组转换为列表 使用 8 个基本类型数组转 ...

  8. HttpAsyncClient的连接池使用

    代码示例 public static void main(String[] args) throws Exception { ConnectingIOReactor ioReactor = new D ...

  9. Spring Scheduler定时任务 + Quartz

    原文地址: https://blog.csdn.net/revitalizing/article/details/61420556 版权声明:本文为博主原创文章,未经博主允许不得转载. https:/ ...

  10. aspnet_regiis -i VS 20XX 的开发人员命令提示符

    1,VS 2010 Setting environment x86 tools. D:\Program Files\Microsoft Visual Studio 10.0\VC>aspnet_ ...