Advertisement
chiplu

Java good and bad array

Nov 17th, 2019
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package dadaproject.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.  
  8.         checker(0,1,10,12,4,5,6,7,8);
  9.     }
  10.     static void checker(int ...m) {
  11.         int counter = 0;
  12.         for (int i = 0; i < m.length; i++) {
  13.             if ((i % 2) != (m[i] % 2))
  14.             {
  15.                 counter = 1;
  16.                 break;
  17.             }
  18.  
  19.         }
  20.         if (counter==1)
  21.         {
  22.             System.out.print("Bad array");
  23.         }
  24.         else
  25.             System.out.print("Good array");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement