当前位置:网站首页>Floating point comparison, CMP, tabulation ideas

Floating point comparison, CMP, tabulation ideas

2022-07-06 13:21:00 Rivers overflow

Floating point comparison

Core part code

cosnt double eps=1e-8;
const double pi=acos(-1.0);
#define Equ(a,b) ((fabs((a)-(b)))<(eps))
#define More(a,b) (((a)-(b))>(eps))
#define Less(a,b) (((a)-(b))<(-eps))
#define MoreEqu(a,b) (((a)-(b))>(-eps))
#define LessEqu(a,b) (((a)-(b))<(eps))

Be careful !abs And fabs

sort Functional cmp

bool cmp(node a,node b)
{
    return a.score<b.score;// Represents the order from small to large 
}

The meter

① Calculate all the results needed in the program at one time , For example, the first few values of fiboracci sequence are directly filled into the array and directly queried

② In procedure b Calculate all the results needed in one or more times , Manually write the results in the program A In the array , And so on

③ Violence is a small-scale result , Looking for a regular

原网站

版权声明
本文为[Rivers overflow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131443056403.html