剑指 Offer 17. 打印从1到最大的n位数

题目链接

17. 打印从1到最大的n位数

思路分析

直接从1到pow(10, n)即可。

class Solution {
public:
    vector<int> printNumbers(int n) {
        std::ios::sync_with_stdio(false);
        vector<int> C;
        for(int i = 1; i < pow(10, n); i++)
            C.push_back(i);
        return C;
    }
};
posted @ 2021-03-30 18:13  蒟蒻颖  阅读(25)  评论(0编辑  收藏  举报