你们看得出问题出哪里了吗?
程序代码:#include <stdio.h>
#include <ctype.h>
int main(void)
{
char answer = 'N';
double total = 0.0;
double value = 0.0;
int count = 0;
printf ("\nThis program calculates the average of any number of values.");
for ( ; ; )
{
printf ("\nEnter a value: ");
scanf ("%lf",&value);
total += value;
++count;
printf ("Do you want to enter another value ? (Y or N):");
scanf ("%c",&answer);//这里本来要用户输入y 或者n确定是否继续循环,但是编译后无法输入y or n,编译一下就明白了。
if (tolower (answer)== 'n')
break;
}
printf ("\nThe average is %.2f\n",total/count);
return 0;
}可能问题描述得不是很清楚,但是大家运行一下就会明白了。
[ 本帖最后由 gino86 于 2010-10-5 00:28 编辑 ]









