当前位置:网站首页>剑指 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;
}
};
边栏推荐
- C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
- 01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
- (最新版) Wifi分销多开版+安装框架
- (latest version) WiFi distribution multi format + installation framework
- The best shortcut is no shortcut
- Differences between initial, inherit, unset, revert and all
- 如何在微信小程序中获取用户位置?
- alright alright alright
- Brief introduction to mvcc
- ORM use of node -serialize
猜你喜欢

Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board

Method overloading and rewriting

4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment

自抗扰控制器七-二阶 LADRC-PLL 结构设计

Record your vulnhub breakthrough record

(latest version) WiFi distribution multi format + installation framework

Application of ncnn neural network computing framework in orange school orangepi 3 lts development board

Alibaba is bigger than sending SMS (user microservice - message microservice)

ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍

Grid connection - Analysis of low voltage ride through and island coexistence
随机推荐
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
Analysis of a music player Login Protocol
【Colab】【使用外部数据的7种方法】
Use Tencent cloud IOT platform to connect custom esp8266 IOT devices (realized by Tencent continuous control switch)
Ali & ant self developed IDE
并网-低电压穿越与孤岛并存分析
initial、inherit、unset、revert和all的区别
Kotlin - 改良装饰者模式
Analysis of the influence of voltage loop on PFC system performance
自抗扰控制器七-二阶 LADRC-PLL 结构设计
对业务的一些思考
Harmonic current detection based on synchronous coordinate transformation
最新版盲盒商城thinkphp+uniapp
十條職場規則
Simple use and precautions of kotlin's array array and set list
An example of newtonjason
【数据挖掘复习题】
[review questions of database principles]
4. 无线体内纳米网:电磁传播模型和传感器部署要点
Apache Mina Development Manual