| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3871 人关注过本帖
标题:大家帮忙看一下 第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
快速回复:大家帮忙看一下 第21行为啥不加空格会错误?vc++6.0下运行 。。
数据加载中...
 
   



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

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