#28. 交换数组首尾元素

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

交换数组首尾元素

Swap First and Last Elements

Background

Dawei is organizing some number sequences, and he wants to perform a simple operation on each sequence.

Problem Description

Given an array of integers, swap the first and last elements in the array. Return the modified array. The array length will be at least 11.

Input Format

Input is given from standard input in the following format.

A single line containing several integers, representing the elements of the array. These integers are separated by spaces.

Output Format

Output to standard output in the following format.

A single line containing the elements of the modified array, formatted as [x, y, z, ...] with elements separated by commas and spaces.

Sample

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

Constraints

  • The length of the array NN satisfies 1N10001 \le N \le 1000.
  • Each element in the array is an integer, and its absolute value does not exceed 10910^9.
  • Time limit: 11 second, Memory limit: 10241024 KiB.