Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enter your code herepackage com.company;
- import java.util.Arrays;
- /**
- * Created by Alex on 26.02.2015.
- */
- public class Massive {
- public static boolean Check(int a) {
- if (a % 2 == 0 && a != 0) {
- return true;
- } else return false;
- }
- public static void main(String[] args) {
- int m[] = new int[15];
- int count = 0;
- for (int i = 0; i < 15; i++) {
- m[i] = ((int) (Math.random() * 9));
- }
- for (int i = 0; i < m.length; i++) {
- System.out.print(m[i] + " ");
- if (Check(m[i]) == true) {
- count++;
- }
- }
- int mDuse[] = new int[count];
- int count1 = 0;
- for (int i = 0; i < m.length; i++) {
- if (Check(m[i]) == true) {
- mDuse[count1] = m[i];
- count1++;
- }
- }
- System.out.println();
- for (int i = 0; i < mDuse.length; i++) {
- System.out.print(mDuse[i] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement