-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain4.java
More file actions
34 lines (29 loc) · 798 Bytes
/
Main4.java
File metadata and controls
34 lines (29 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
/**
* Created by LXF on 2017/8/12.
*/
public class Main4 {
public static int[] nx(int n, int[] x) {
int[] result = new int[n];
if (n % 2 == 1) {
result[n / 2] = x[0];
}
for (int i = n-1,j = 0; i > 0; i=i-2,j++) {
result[j] = x[i];
result[n - j-1] = x[i - 1];
}
return result;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = scanner.nextInt();
}
int[] result = nx(n, x);
for (int i = 0; i < n; i++) {
System.out.print(result[i]+ (i==n-1?"\n":" "));
}
}
}