#include
#include
int main (void)
{
      char answer ='n';
      double total = 0.0;
      double value =0.0;
      int count = 0;
      for (; ; ) {
            printf("\nenter a value.");
            scanf("%lf",&value);
            total=value+total;
            count++;
            printf("\ndo you want to enter another number?(y or n):");
            scanf("%c",&answer);
            if(tolower(answer)=='n')
            break;
      }
      printf("\n the average is %f",total/count);
      return 0;
}
运行了之后
enter a value.14
do you want to enter another number?(y or n):
enter a value.
请问怎么解决
回答:
printf("\ndo you want to enter another number?(y or n):");
scanf("\n%c",&answer);