当前位置:网站首页>剑指 Offer 17. 打印从1到最大的n位数
剑指 Offer 17. 打印从1到最大的n位数
2022-07-03 12:10:00 【嗝~~~~】
剑指 Offer 17. 打印从1到最大的n位数
难度简单229收藏分享切换为英文接收动态反馈
输入数字 n,按顺序打印出从 1 到最大的 n 位十进制数。比如输入 3,则打印出 1、2、3 一直到最大的 3 位数 999。
示例 1:
输入: n = 1输出: [1,2,3,4,5,6,7,8,9]
说明:
- 用返回一个整数列表来代替打印
- n 为正整数
代码
class Solution {
public:
vector<int> printNumbers(int n) {
vector<int> res(pow(10,n)-1);
for(int i=1;i<=pow(10,n)-1;i++){
res[i-1]=i;
}
return res;
}
};
边栏推荐
- RedHat5 安装Socket5代理服务器
- It feels great to know you learned something, isn‘t it?
- Express abstract classes and methods
- 【习题五】【数据库原理】
- [exercise 5] [Database Principle]
- Tensorflow binary installation & Failure
- The upward and downward transformation of polymorphism
- How to stand out quickly when you are new to the workplace?
- Redhat5 installing socket5 proxy server
- Swift Error Handling
猜你喜欢

Grid connection - Analysis of low voltage ride through and island coexistence

Social community forum app ultra-high appearance UI interface
![[comprehensive question] [Database Principle]](/img/d7/8c51306bb390e0383a017d9097e1e5.png)
[comprehensive question] [Database Principle]

社交社区论坛APP超高颜值UI界面

Node. Js: use of express + MySQL

Powerful avatar making artifact wechat applet

【数据库原理及应用教程(第4版|微课版)陈志泊】【第三章习题】

最新版抽奖盲盒运营版

Low code platform international multilingual (I18N) technical solution

Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
随机推荐
Deeply understand the mvcc mechanism of MySQL
Dojo tutorials:getting started with deferrals source code and example execution summary
Swift return type is a function of function
【数据挖掘复习题】
Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315
Do you feel like you've learned something and forgotten it?
context. Getexternalfilesdir() is compared with the returned path
How to convert a decimal number to binary in swift
并网-低电压穿越与孤岛并存分析
高效能人士的七个习惯
[combinatorics] permutation and combination (multiple set permutation | multiple set full permutation | multiple set incomplete permutation all elements have a repetition greater than the permutation
Harmonic current detection based on synchronous coordinate transformation
Xctf mobile--app3 problem solving
Low code platform international multilingual (I18N) technical solution
Loan calculator my pressure is high
[data mining review questions]
Kung Fu pays off, and learning is done
Two solutions of leetcode101 symmetric binary tree (recursion and iteration)