SHARE
TWEET

Untitled

advictoriam Jan 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Numbers
  2. {
  3.    /**
  4.       Computes the number of even and odd values in a given array
  5.       @param values an array of integer values
  6.       @return an array of length 2 whose 0 entry contains the count
  7.       of even elements and whose 1 entry contains the count of odd
  8.       values
  9.    */
  10.    public int[] evenOdds(int[] values)
  11.    {
  12.       int[] evenOdd = new int[2];
  13.       for(int a : values){evenOdd[(a%2 == 0) ? 0 : 1] += 1;}
  14.       return evenOdd;
  15.    }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top