题解 | #牛牛的特殊数游戏#

牛牛的特殊数游戏

https://www.nowcoder.com/practice/f2512f68edf94e9b83a37b2b858de645

#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @return string字符串vector
     */
    vector<string> specialNumber(int n) {
        
        vector<string> res;
        for (int i=1; i<=n; i++) {
            string tmp;
            if(i%3==0) tmp+="Now";		//3整除
            if(i%5==0) tmp+="coder";		//5整除
            else if(i%5 && i%3) tmp=std::to_string(i);
            res.push_back(tmp);
        }
        return res;
    }
};

全部评论

相关推荐

星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务