LintCode (9)Fizz Buzz

下面是AC代码,C++风格:
class Solution {
public:
vector<string> fizzBuzz(int N) {
vector<string> Answer;
for(int i = ;i <= N;i++) {
if(i % == ) {
Answer.push_back("fizz buzz");
} else if(i % == ) {
Answer.push_back("fizz");
} else if(i % == ) {
Answer.push_back("buzz");
} else{
Answer.push_back(to_string(i));
}
}
return Answer;
}
};
此处很奇怪,为何将成员函数名fizzBuzz的首字母改成大写,编译返回不通过?
Main.cpp: In function ‘int main()’:
Main.cpp:26:39: error: ‘class Solution’ has no member named ‘fizzBuzz’
vector results = solution.fizzBuzz(n);
^
EXITCODE=1
LintCode (9)Fizz Buzz的更多相关文章
- Lintcode 9.Fizz Buzz 问题
------------------------ AC代码: class Solution { /** * param n: As description. * return: A list of s ...
- LintCode: Fizz Buzz
C++ class Solution { public: /** * param n: As description. * return: A list of strings. */ vector&l ...
- [容易]Fizz Buzz 问题
题目来源:http://www.lintcode.com/zh-cn/problem/fizz-buzz/
- [LeetCode] Fizz Buzz 嘶嘶嗡嗡
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
- 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 ...
- [重构到模式-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 ...
随机推荐
- linux 内核源代码分析 - 获取数组的大小
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 測试程序: #include<stdio.h> #include<stdlib. ...
- 响应式流布局插件DyLay
jQuery插件-Dylay,流布局我们前面介绍过很多,但这个流布局jQuery插件不同的是它的动画效果很不错,大家可以尝试使用下.另外<有用的jQuery布局插件推荐>这篇文章中有好几个 ...
- 【MFC学习笔记-作业10-稍微难一点的画图】
设计如图所示的菜单,并编写相应用的消息处理函数.. 菜单1: 画图 画线 画矩形 画图 菜单2:颜色 红色(r) CTRL+F2; 绿色(g) CTRL +F1 蓝色(b) CTRL+F3: 问题:V ...
- 页面按F5重复提交数据解决方法
在Web开发中,必须面对的问题就是表单的重复提交问题(这里仅指F5刷新造成的重复提交),.NET中处理这个问题似乎没有什么好的方法. 在网上搜索得到的解决方法主要有两种,一种是直接让表单按钮失效,从而 ...
- ASP.NET程序代码优化的七个方面
ASP.NET程序性能优化的七个方面 一.数据库操作 1.用完马上关闭数据库连接 访问数据库资源需要创建连接.打开连接和关闭连接几个操作.这些过程需要多次与数据库交换信息以通过身份验证,比 ...
- Linux 重定向
Linux 标准文件描述符 描述符 缩写 描述 0 STDIN 标准输入 1 STDOUT 标准输出 2 STDERR 标准错误 3-9 应该是扩展的标准输出(待验证) 命令行重定 ...
- C#中的多线程-入门
概述与概念C#支持通过多线程并行地执行代码,一个线程有它独立的执行路径,能够与其它的线程同时地运行.一个C#程序开始于一个单线程,这个单线程是被CLR和操作系统(也称为“主线程”)自动创建的,并具有多 ...
- C# 2 闰年平年 老狼几点了
作业 第一题 老狼几点了.凌晨,上午,下午,晚上. static void Main (string[] args) { //输入 Console.Write("老狼老狼几点了?" ...
- HDU 1027 - Ignatius and the Princess II
第 m 大的 n 个数全排列 DFS可过 #include <iostream> using namespace std; int n,m; ]; bool flag; ]; void d ...
- 阿牛的EOF牛肉串
#include <iostream>using namespace std;long long s0,s1,s2,s3;int main(){ int i,n; while(cin> ...