| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 385 人关注过本帖
标题:高手帮我看看,为什么输出的结果不对!!!!!谢谢了。。。
取消只看楼主 加入收藏
zhongyong123
Rank: 2
等 级:论坛游民
帖 子:45
专家分:15
注 册:2008-12-16
结帖率:75%
收藏
已结贴  问题点数:10 回复次数:4 
高手帮我看看,为什么输出的结果不对!!!!!谢谢了。。。
只是一个简单的米和英尺转化的程序,我设置的精度为double,结果显示错误,请帮我查找下错误:
double\float到底有什么区别呢???
#include <stdio.h>

double Transform1();
double Transform2();
void main() //meter and feet bilateral transform
{

    printf("please choose the mode you want to transform:\n");
    printf("a. from meter to feet\n");
    printf("b. from feet to meter\n");
    char s;
    s =    getchar();

    switch(s)
    {
   
    case 'a': Transform1();break;
    case 'b': Transform2();break;

    }

}


double Transform1()
{

    printf("you have selected the mode (from meter to feet), please input the number:\n");
    double temp, res;
    scanf("%f",&temp);
    res=temp*3.28;
    printf("the result is :%f\n",res);
    return res;
}

double Transform2()
{

    printf("you have selected the mode (from feet to meter), please input the number:\n");
    double temp, res;
    scanf("%f",&temp);
    res=temp*0.3;
    printf("the result is :%f\n",res);
    return res;
}

搜索更多相关主题的帖子: 结果 输出 
2010-11-17 20:23
zhongyong123
Rank: 2
等 级:论坛游民
帖 子:45
专家分:15
注 册:2008-12-16
收藏
得分:0 
返回给函数啊!!不对吗??
2010-11-17 20:37
zhongyong123
Rank: 2
等 级:论坛游民
帖 子:45
专家分:15
注 册:2008-12-16
收藏
得分:0 
与那个好像关系不大吧??好像把double改成float 就对了!不明白原因,愿高手解答!!
2010-11-17 20:42
zhongyong123
Rank: 2
等 级:论坛游民
帖 子:45
专家分:15
注 册:2008-12-16
收藏
得分:0 
谢谢啊
2010-11-17 20:48
zhongyong123
Rank: 2
等 级:论坛游民
帖 子:45
专家分:15
注 册:2008-12-16
收藏
得分:0 
感觉到了差距
2010-11-17 20:55
快速回复:高手帮我看看,为什么输出的结果不对!!!!!谢谢了。。。
数据加载中...
 
   



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

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