标题:大家帮忙看一下 第21行为啥不加空格会错误?vc++6.0下运行 。。
取消只看楼主
beichei5d
Rank: 4
等 级:业余侠客
威 望:2
帖 子:89
专家分:270
注 册:2016-3-8
结帖率:100%
已结贴  问题点数:10 回复次数:1 
大家帮忙看一下 第21行为啥不加空格会错误?vc++6.0下运行 。。
# include <stdio.h>
# include <ctype.h>

int main(void)
{
    char answer = 'N';
    double total = 0.0;
    double value = 0.0;
    unsigned int count = 0;

    printf("This program calculates the average of any number of value.\n");

    for(;;)
    {
        printf("\nEnter a value: ");
        scanf("%lf", &value);
        total = total + value;
        ++count;
        printf("Do you want to enter another value? ( Y or N):");
        scanf(" %c", &answer); // 为啥 %c前面要加空格?
        if(tolower(answer) == 'n')
            break;
    }
    printf("\nThe average is %.2lf\n", total/count);
    return 0;
}
搜索更多相关主题的帖子: another average include double number 
2017-04-07 08:58
beichei5d
Rank: 4
等 级:业余侠客
威 望:2
帖 子:89
专家分:270
注 册:2016-3-8
得分:0 
回复 2楼 grmmylbs
还是不理解,,我在想想。。

你现在所偷的懒,都将成为以后扇你的巴掌!共勉吧。。。
2017-04-07 10:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-475855-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.524843 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved