LeetCode刷題:打印從1到最大的n位數(C#)

輸入數字 n,按順序打印出從 1 到最大的 n 位十進制數。比如輸入 3,則打印出 1、2、3 一直到最大的 3 位數 999。

來源:力扣(LeetCode)
鏈接:https://leetcode-cn.com/problems/da-yin-cong-1dao-zui-da-de-nwei-shu-lcof/
著作權歸領釦網絡所有。商業轉載請聯繫官方授權,非商業轉載請註明出處。

public class Solution {
    public int[] PrintNumbers(int n) {
        int []nums=new int [(int)System.Math.Pow(10,n)-1];
        for(int i=1;i<(int)System.Math.Pow(10,n);i++){
            nums[i-1]=i;
        }
        return nums;
    }
}

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章