当前位置:网站首页>剑指 Offer 17. 打印从1到最大的n位数
剑指 Offer 17. 打印从1到最大的n位数
2022-08-08 03:13:00 【嗝~~~~】
剑指 Offer 17. 打印从1到最大的n位数
难度简单
输入数字 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);
int i;
//printf("1");
//printf("%d\n",pow(n+1,10));
for( i=0;i<pow(10,n)-1;i++ ){
res[i]=i+1;
// printf("%d",i);
}
return res;
}
};
边栏推荐
猜你喜欢

DolpinScheduler

期货公司有各种的开户手续费

egg-validate-自定义校验方法报错语言(报错中文提示)

意识的概念框架:我们的意识从注意图式产生?

The ORACLE database connection exception after restart

RV-GAN:使用新的多尺度生成对抗网络分割眼底照片中的视网膜血管结构

Nanny level tutorial!Golang microservices simple architecture in practice

Kubernetes Technology and Architecture (8)

Several daily LeetCode exercises

KDD'22 | CausalMTA: 基于因果推断的无偏广告多触点归因技术
随机推荐
Redis-事物
The fourth chapter of the original CSharp c # common years is hard to know the humanistic one after another
音视频基础
hreg说明备忘
Detailed QML ListView
The sock MySQL start failure caused by lock file
Win11右键恢复经典win10最简单方法(基本0操作)
Simulate login - add cookies, use postmanget to request web page data
C#《原CSharp》第四回 人常见岁月更替 却难知人文相继
Optional中orElse和orElseGet的区别
KDD'22 | CausalMTA: 基于因果推断的无偏广告多触点归因技术
RV-GAN:使用新的多尺度生成对抗网络分割眼底照片中的视网膜血管结构
【建议收藏】百分百全套中高级Android面试题
The easiest way to restore classic win10 by right-clicking on Win11 (basic 0 operation)
Online futures account opening is becoming more and more popular
ICML 2022 | LeNSE: Subgraph-Based Large-Scale Combinatorial Optimization: Achieving Over 140x Speedup
CS8630 无效的 nullable 值: C# 7.3 的“Enable”
Embedded Interview Questions
DisplayPort-DP接口知识
【我的日志】关于我可爱的新同事