fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. int x;
  10. Vector Odd = new Vector();
  11. Vector Even = new Vector();
  12. Scanner in = new Scanner(System.in);
  13.  
  14. while(true)
  15. {
  16. try{
  17. x = in.nextInt();
  18.  
  19. if(x%2==0) Even.addElement(x);
  20. else Odd.addElement(x);
  21. }
  22. catch (Exception obj)
  23. {
  24.  
  25. break;
  26. }
  27. }
  28. for(int i=0;i<Even.size();i++)
  29. {
  30. System.out.print(Even.get(i) + " ");
  31. }
  32. System.out.print("\n");
  33. for(int i=0;i<Odd.size();i++)
  34. {
  35. System.out.print(Odd.get(i) + " ");
  36. }
  37. }
  38. }
Success #stdin #stdout 0.13s 29380KB
stdin
1 2 3 4 5 6 7 8 9 
stdout
2 4 6 8 
1 3 5 7 9