当前位置:网站首页>剑指 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;
}
};
边栏推荐
- Quick learning 1.8 front and rear interfaces
- Simple use and precautions of kotlin's array array and set list
- How to convert a decimal number to binary in swift
- Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
- C graphical tutorial (Fourth Edition)_ Chapter 20 asynchronous programming: examples - using asynchronous
- 【数据库原理复习题】
- Nodejs+Express+MySQL实现登陆功能(含验证码)
- The latest version of blind box mall thinkphp+uniapp
- 4. 无线体内纳米网:电磁传播模型和传感器部署要点
- [network counting] Chapter 3 data link layer (2) flow control and reliable transmission, stop waiting protocol, backward n frame protocol (GBN), selective retransmission protocol (SR)
猜你喜欢

Differences between initial, inherit, unset, revert and all

Quick learning 1.8 front and rear interfaces

Xctf mobile--app3 problem solving

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

studio All flavors must now belong to a named flavor dimension. Learn more

【数据库原理复习题】

Dojo tutorials:getting started with deferrals source code and example execution summary

Ali & ant self developed IDE

Xctf mobile--rememberother problem solving

The latest version of lottery blind box operation version
随机推荐
context. Getexternalfilesdir() is compared with the returned path
Oh my Zsh + TMUX installation
高效能人士的七个习惯
Detailed explanation of the most complete constraintlayout in history
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep271
启用MemCached的SASL认证
Powerful avatar making artifact wechat applet
【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
Write a simple nodejs script
CNN MNIST handwriting recognition
Togaf certification self-study classic v2.0
Do you feel like you've learned something and forgotten it?
【数据库原理复习题】
Seven second order ladrc-pll structure design of active disturbance rejection controller
【数据挖掘复习题】
Alibaba is bigger than sending SMS (user microservice - message microservice)
Ali & ant self developed IDE
[data mining review questions]
Cache penetration and bloom filter