基本的函数

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?
");
    scanf("%lf",&response);
    while (fabs(response - answer) > 0.0001) {
        printf("Try again 
");
        scanf("%lf",&response);
    }
    printf("Close enough!
");
    return 0;
}
将来的自己,会感谢现在不放弃的自己!
原文地址:https://www.cnblogs.com/TheYouth/p/5064965.html