C语言的一个小问题#include#includeint 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);

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/24 16:50:08
C语言的一个小问题#include#includeint main(void){char answer='N';double total=0.0;double value=0.0;int count=0;printf(
x]OAʄDE[zěaM2biBSE VGJm Qi[3;˿qvMx@yss6S~u/e͊+۽~99ӉbXy5։Nee3IqQerl&S+gȤ&6T" %lX. jSN N%"*0:RX6"2UK*s*Z$"BNep]H6`{}lVv=I3ijBƷ6 "bivumHW?;Ϛ7O?oW]8;Mg }e@0WpQ֡ byWY_NgVժSgs^+^j L_o[c\

C语言的一个小问题#include#includeint 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);
C语言的一个小问题
#include
#include
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 get an another answer?(Y or N)");
scanf(" %c",&answer);
if(tolower(answer)=='n');
break;
}
printf("\nThe average is %.2lf\n",total/count);
getchar();
return 0;
}
第二个scanf 输入里面 输入 y直接跳出了循环?不执行for循环.为什么啊.

C语言的一个小问题#include#includeint 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);
你的if后面是分号 这样if不执行判断 直接完成这句 也就是if语句无效了 直接执行break;了
if(tolower(answer)=='n');
break;
而且scanf(" %c",&answer);这句为什么%c前面还有2个空格?
先把代码写规范吧.