Title describes the first line to enter a number, N, the second line to enter n number, this n number, if even more than an odd number, output no, otherwise output yes.
Input Description:
Enter more than one set of data.
Enter n for each group, and then enter n integers (1<=n<=1000).
Output Description:
If the even number is more than odd, output no, otherwise the output is yes.
Input Example:
5
1 5 2) 4 3
Output Example:
YES
Code:
ImportJava.util.Scanner; Public classcompare odd and even number of characters { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); while(In.hasnext ()) {intCount =In.nextint (); int[] num =New int[Count]; intFlag1 = 0, Flag2 = 0;//Flag1 record Odd for(inti = 0; I < count; i++) {Num[i]=In.nextint (); if(Num[i]% 2 = = 0) {Flag2++; } ElseFlag1++; } BooleanTag = Flag1 >= flag2?true:false; if(TAG) System.out.println ("YES"); ElseSystem.out.println ("NO"); } in.close (); }}
Compare odd and even number of numbers