Advertisement
Alex_Zuev

Untitled

Feb 26th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. Enter your code herepackage com.company;
  2. import java.util.Arrays;
  3.  
  4. /**
  5.  * Created by Alex on 26.02.2015.
  6.  */
  7. public class Massive {
  8.     public static boolean Check(int a) {
  9.         if (a % 2 == 0 && a != 0) {
  10.             return true;
  11.         } else return false;
  12.     }
  13.  
  14.  
  15.     public static void main(String[] args) {
  16.         int m[] = new int[15];
  17.         int count = 0;
  18.         for (int i = 0; i < 15; i++) {
  19.             m[i] = ((int) (Math.random() * 9));
  20.         }
  21.         for (int i = 0; i < m.length; i++) {
  22.             System.out.print(m[i] + " ");
  23.             if (Check(m[i]) == true) {
  24.                 count++;
  25.             }
  26.         }
  27.         int mDuse[] = new int[count];
  28.         int count1 = 0;
  29.         for (int i = 0; i < m.length; i++) {
  30.  
  31.             if (Check(m[i]) == true) {
  32.                 mDuse[count1] = m[i];
  33.                 count1++;
  34.  
  35.             }
  36.         }
  37.         System.out.println();
  38.         for (int i = 0; i < mDuse.length; i++) {
  39.             System.out.print(mDuse[i] + " ");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement