题解 | #牛牛的特殊数游戏#
牛牛的特殊数游戏
https://www.nowcoder.com/practice/f2512f68edf94e9b83a37b2b858de645
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return string字符串vector */ vector<string> specialNumber(int n) { // write code here vector<string> str; for(int i = 1; i < n+1; ++i) { if(i%3!=0 && i%5!=0 ) str.push_back(to_string(i)); else if(i%3==0 && i%5==0 ) str.push_back("Nowcoder"); else if(i%3==0) str.push_back("Now"); else str.push_back("coder"); } return str; } };