shuffle/Shuffle_Calvin.java
1 import java.util.Scanner;
2
3 public class Shuffle_Calvin {
4 public static void main(String[] args) {
5 Scanner in = new Scanner(System.in);
6 while (in.hasNextLine()) {
7 int n = Integer.parseInt(in.nextLine());
8 String[] data = new String[n];
9 for (int i = 0; i < n; ++i) {
10 data[i] = in.nextLine();
11 }
12 int offset = n/2;
13 if (n % 2 == 1) {
14 ++offset;
15 }
16 String[] result = new String[n];
17 for (int i = 0; i < n/2; ++i) {
18 result[i*2] = data[i];
19 result[i*2+1] = data[i+offset];
20 }
21 if (n%2 == 1) {
22 result[result.length-1] = data[n/2];
23 }
24 for (int i = 0; i < result.length; ++i) {
25 System.out.println(result[i]);
26 }
27 }
28 in.close();
29 }
30 }