#include "stdio.h"
int main()
{
int count1=0,count2=0,i;
while(1)
{
脊枣 scanf("%d",&i);
樱明拆if(i==-1)
break;
else if(i%2==0)
槐哗 count1++;
else if(i%2==1)
count2++;
}
printf("奇数共有%d个,偶数共有%d个.\n",count2,count1);
}
#include<stdio.h>
int main()
{
int even,odd,n;
迅拦 even=odd=0;
while(scanf("%d",&n)!=EOF)
扒燃 {
if(n==-1) break;
if(n%2==0) even++;
else odd++;
亩此胡 }
printf("偶数=%d个 奇数=%d个\n",even,odd);
return 0;
}
负数也有奇偶之分,输入的-1也是奇数,0也是特殊偶数
#include<stdio.h>
int main()
{
int i;
int a=0,b=0;
scanf("%d",&i);
while(i!=-1)
{
if(i%2==0)a++;
else b++;
scanf("%d"册搏磨银腔,&i);
}
printf("奇数有%d个,偶数州斗有%d个\n",b,a);
}