首页 > 其他 > 详细

基本的函数

时间:2015-12-21 23:16:30      阅读:233      评论:0      收藏:0      [点我收藏+]

fabs 是计算绝对值  %lf 是代表double类型.

下面是个小例子,浮点数比较

//浮点数比较
#include <stdio.h>
#include <math.h>
int main (void){
    const double answer = 3.1415926;
    double response;
    printf("what is value of pi?\n");
    scanf("%lf",&response);
    while (fabs(response - answer) > 0.0001) {
        printf("Try again \n");
        scanf("%lf",&response);
    }
    printf("Close enough!\n");
    return 0;
}

 

基本的函数

原文:http://www.cnblogs.com/TheYouth/p/5064965.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!