简单的问题。帮我看下这个程序错哪了
#include <stdio.h>#include <math.h>
int main (void)
{
int n;
double sum_odd=0.0,sum_even=0;
double ct_odd=0,ct_even=0;
while (scanf("%d",&n)==1 && n!=0)
{
if (n % 2 == 1)
{ sum_odd += n;
++ct_odd;
}
else
{ sum_even += n;
++ct_even;
}
}
printf ("Number of evens: %d",sum_even);
if (ct_even > 0) printf (" average : %Lf",sum_even/ct_even);
printf ("\n");
printf ("Nunber of odd : %d",sum_odd);
if (ct_odd > 0) printf (" average : %Lf",sum_odd/ct_odd);
printf("\n");
}
为什么"Number of evens 和odd都是0呢
[ 本帖最后由 yuanye2416 于 2012-10-25 15:12 编辑 ]