C ++中的fdim()
在这里,我们将看到fdim()C++中的功能是什么。该fdim()函数用于返回两个给定参数之间的正差。如果两个参数分别是a和b,并且如果a>b,则它将返回a–b。否则返回0。
示例
#include <cmath>
#include <iostream>
using namespace std;
main() {
cout << "fdim of (5.0, 2.0) is " << fdim(5.0, 2.0) << endl; //positive difference
cout << "fdim of (2.0, 5.0) is " << fdim(2.0, 5.0) << endl; //this will return 0
cout << "fdim of (-5.0, -2.0) is " << fdim(-5.0, -2.0) << endl; //this will return 0
cout << "fdim of (-2.0, -5.0) is " << fdim(-2.0, -5.0) << endl; //positive difference
}输出结果
fdim of (5.0, 2.0) is 3 fdim of (2.0, 5.0) is 0 fdim of (-5.0, -2.0) is 0 fdim of (-2.0, -5.0) is 3
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短