#29. 提取数组中间三元素

    ID: 29 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp3一维数组

提取数组中间三元素

Middle Three Elements

Background

Congcong is learning array operations and encountered an interesting problem that requires extracting specific elements from a given array.

Problem Description

Given an array of integers of odd length, return a new array of length 33 containing the elements from the middle of the array. The array length will be at least 33.

Input Format

Input is given from Standard Input in the following format.

A single line containing space-separated integers, representing the elements of the array.

Output Format

Output is printed to Standard Output in the following format.

Output a new array of length 33 with the middle three elements of the original array. The elements should be comma-separated and enclosed in square brackets [].

Sample

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

Sample Explanation

For an array of length NN, the middle element's index is N/2N/2 (integer division). We need to extract the three elements at indices N/21N/2 - 1, N/2N/2, and N/2+1N/2 + 1.

Constraints

1s, 1024KiB for each test case.