shuffle/Shuffle_artur.java

  1 import java.io.BufferedReader;
  2 import java.io.InputStreamReader;
  3 
  4 public class Shuffle_artur {
  5 
  6   public static void main(String[] args) throws Exception {
  7     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  8     for (int n = Integer.parseInt(in.readLine()); n != 0; n = Integer.parseInt(in.readLine())) {
  9       String[] card = new String[n];
 10       for (int i = 0; i < n; i++)
 11         card[i] = in.readLine();
 12       boolean left = true;
 13       for (int i = 0, j = (n + 1) / 2, k = 0; k < n; left = !left, k++)
 14         if (left)
 15           System.out.println(card[i++]);
 16         else
 17           System.out.println(card[j++]);
 18     }
 19   }
 20 }