forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
50 lines (47 loc) · 1.36 KB
/
Test.java
File metadata and controls
50 lines (47 loc) · 1.36 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package NiuKeWang;/**
* @Classname Test
* @Description TODO
* @Date 19-3-17 下午3:03
* @Created by mao<[email protected]>
*/
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class Test{
public static void main(String[] args)throws IOException{
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader bf=new BufferedReader(ir);
int n=Integer.parseInt(bf.readLine());
String[] s=bf.readLine().split(" ");
int[] nums=new int[n];
for(int i=0;i<n;i++){
nums[i]=Integer.parseInt(s[i]);
}
if(nums.length==1){
System.out.print(nums[0]);
return;
}
if(nums.length==2){
System.out.print(nums[1]+" ");
System.out.print(nums[0]);
return;
}
if(n%2==0){
for(int i=n-1;i>0;i=i-2){
System.out.print(nums[i]+" ");
}
for(int j=0;j<n-2;j=j+2){
System.out.print(nums[j]+" ");
}
System.out.print(nums[n-2]);
}else{
for(int i=n-1;i>=0;i=i-2){
System.out.print(nums[i]+" ");
}
for(int j=1;j<n-2;j=j+2){
System.out.print(nums[j]+" ");
}
System.out.print(nums[n-2]);
}
}
}