// create a linked list with random numbers 
// then have a function split that creates 2 lists - one even - 1 odd
// can do this 2 ways - 1 destroying original list and the other 
// keeping it intact - this one empties original

import java.io.*;
import java.util.*;


public class linked
 {public static input in = new input();   // input library
   public static final int MAX = 20;


  // fill with random numbers

  public static void fill(LinkedList q)
   {for (int x=1; x <= MAX; x++)
      q.add(new Integer((int)(Math.random()*100)));
}

// split list in 2 with odd and even

public static void split(LinkedList q,LinkedList e,LinkedList o)
 {Integer n;
   while (q.size()>0)    // have to be careful - for loop 1 <= q.size only goes 1/2 way
    {n = q.removeFirst();
     if (n.intValue() % 2 ==0)
       e.add(n);
      else
        o.add(n);
	 }
 }

  public static void main(String[] args) throws IOException  // always need main program
   {LinkedList q = new LinkedList();
   LinkedList e = new LinkedList();
   LinkedList o = new LinkedList();
   fill(q);
   System.out.println(q);
   split(q,o,e);
   System.out.println(o);
   System.out.println(e);
   }
}