到底是不是太胖了

 1 /*
 2     邮件:xuejineng2016@163.com
 3     2020年5月5日
 4     这个题目重点考核浮点数比较大小的问题,头有点大。
 5  */
 6 #include <stdio.h>
 7 #include <math.h>
 8 #define EPS 1e-6
 9 int main(void)
10 {
11     int n;
12     double height, weight;
13     double std_weight;
14     double t1,t2;
15     int i;
16     
17     scanf("%d", &n);
18     for (i = 0; i < n; i++) {
19         scanf("%lf %lf", &height, &weight);
20         //标准体重
21         std_weight = (height - 100) * 0.9;
22         //将实际体重换算成公斤
23         weight = weight / 2;
24         //用这两个临时变量,是避免表达式写的太长了
25         t1 = fabs(weight - std_weight);
26         t2 = std_weight * 0.1;
27         
28         if (t1 < t2 && fabs(t1 - t2) > EPS) {
29             printf("You are wan mei!
");
30         }
31         //大约等于
32         if (weight > std_weight * 1.1 || fabs(weight - std_weight * 1.1) < EPS)
33         {
34             printf("You are tai pang le!
");
35         }
36         //小于等于
37         if (weight < std_weight * 0.9 || fabs(weight - std_weight * 0.9) < EPS)
38         {
39             printf("You are tai shou le!
");
40         }
41     }
42     
43     return 0;
44 }
原文地址:https://www.cnblogs.com/2018jason/p/12842430.html