#77. 创建递增序列数组

    ID: 77 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-2gesp3一维数组循环结构

创建递增序列数组

Create Increasing Array

Background

This problem asks you to implement a basic array creation function.

Problem Description

Given an integer nn, create and return a new integer array of length nn, containing the numbers 0,1,2,,n10, 1, 2, \dots, n-1. The given nn may be 00, in which case just return a length 00 array. You do not need a separate if-statement for the length-00 case; the for-loop should naturally execute 00 times in that case, so it just works. The syntax to make a new integer array is: new int[desired_length].

Input Format

Input is given from standard input in the following format.

n

Output Format

Output is printed to standard output in the following format.

[0, 1, ..., n-1]

Sample

4
[0, 1, 2, 3]
1
[0]
10
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Sample Explanation

For Sample 1, given n=4n=4, the output is an array containing 0,1,2,30, 1, 2, 3. For Sample 2, given n=1n=1, the output is an array containing 00. For Sample 3, given n=10n=10, the output is an array containing numbers from 00 to 99.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.