public class test {
public static void main(String[] args)
{
int ou_count=0,ji_count=0;
int num[]={'0','1','2','3'};//数组初始化
for(int i=0;i<4;i++)//遍历数组
{
if(num[i]%2==0)//对2取余,如果为0就是偶数,否则就为奇数
ou_count++;//偶数个数加一
else
ji_count++;//奇数个数加一
}
System.out.println("偶数的个数是:"+ou_count);
System.out.println("奇数的个数是:"+ji_count);
}
}
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] ints = {2,3,5,9,8,1};//初始化数组
int Osums = 0;//偶数个数
int Jsums = 0;//奇数个数
for(int i = 0; i < ints.length;i++){//循环数组
if(ints[i]%2==0){//取余数
Osums++;
}else{
Jsums++;
}
}
System.out.println("偶数个数:"+Osums);
System.out.println("奇数个数:"+Jsums);
}
}