Fizz Buzz

 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;
}
};
上一篇:Discuz! x 2.5-3.0 beta 存储型跨站漏洞


下一篇:SQL Server中调用WebService的实例