#26. 提取数组中间两元素
提取数组中间两元素
Extract Middle Two Elements
Background
In a world full of numbers, you often need to quickly locate key information from a series of data. Now, you need to find the two most central elements from an array.
Problem Description
Given an array of integers of even length, return a new array of length containing the middle two elements from the original array. The original array will be of length or more.
Input Format
Input is given from standard input in the following format.
An array of integers, with elements separated by spaces and enclosed in square brackets
[].
Output Format
Output is printed to standard output in the following format.
An array of integers, containing the middle two elements from the original array, with elements separated by a comma and space
,and enclosed in square brackets[].
Sample
[1 2 3 4]
[2, 3]
[7 1 2 3 4 9]
[2, 3]
[1 2]
[1, 2]
Sample Explanation
For Sample , the array [1 2 3 4] has a length of . The two middle elements are at indices and , which are and .
For Sample , the array [7 1 2 3 4 9] has a length of . The two middle elements are at indices and , which are and .
For Sample , the array [1 2] has a length of . The two middle elements are at indices and , which are and .
Constraints
Time limit: second, Memory limit: KiB for each test case.