Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Numbers
- {
- /**
- Computes the number of even and odd values in a given array
- @param values an array of integer values
- @return an array of length 2 whose 0 entry contains the count
- of even elements and whose 1 entry contains the count of odd
- values
- */
- public int[] evenOdds(int[] values)
- {
- int[] evenOdd = new int[2];
- for(int a : values){evenOdd[(a%2 == 0) ? 0 : 1] += 1;}
- return evenOdd;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment