看看我这段代码,scanf以后就停住了
#include<stdio.h>#define STOP '#'
int main(void)
{
int num,even=0,odd=0;
float even_sum=0,odd_sum=0,even_aver,odd_aver;
printf("Now enter some integers(press 0 to quit)\n");
scanf_s("%d",&num);
while(num!=0)
{
if(num%2==0)
{
even++;
even_sum+=num;
}
else
{
odd++;
odd_sum+=num;
}
scanf("%d",&num);
}
even_aver=even_sum/even;
odd_aver=odd_sum/odd;
printf("Evens are %d,and its average is %5.2f\n",even,even_aver);
printf("Odds are %d,and its average is %5.2f\n",odd,odd_aver);
}
这样就好了
[ 本帖最后由 chinagdvea 于 2009-11-7 13:30 编辑 ]