题解 | #打印从1到最大的n位数#

打印从1到最大的n位数

https://www.nowcoder.com/practice/4436c93e568c48f6b28ff436173b997f

#include <vector>
class Solution {
public:
    vector<int> printNumbers(int n) {
        // write code here
        int res = 1;
        while(n){// 获取上限
            res *= 10;
            n--;
        }
        vector<int> res_v;
        for(int i = 1; i < res; ++i)// 填充返回值
        {
            res_v.push_back(i);
        }
        return res_v;
    }
};

挤挤刷刷! 文章被收录于专栏

记录coding过程

全部评论

相关推荐

嵌入式求职之路:可以看我经验😂,https://www.nowcoder.com/share/jump/73221730841876945
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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